Bug 265687 - openjdk11 fails due to -Wbitwise-instead-of-logical
Summary: openjdk11 fails due to -Wbitwise-instead-of-logical
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Stefan Eßer
URL:
Keywords:
Depends on:
Blocks: 251774
  Show dependency treegraph
 
Reported: 2022-08-07 11:54 UTC by Stefan Eßer
Modified: 2023-08-01 04:04 UTC (History)
6 users (show)

See Also:


Attachments
Store attachment as "files/patch-src_java.desktop_share_native_libharfbuzz_hb-ot-layout-gpos-table.hh" (1.13 KB, patch)
2022-08-07 11:54 UTC, Stefan Eßer
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Eßer freebsd_committer freebsd_triage 2022-08-07 11:54:08 UTC
Created attachment 235740 [details]
Store attachment as "files/patch-src_java.desktop_share_native_libharfbuzz_hb-ot-layout-gpos-table.hh"

On -CURRENT building openjdk11 fails with warnings treated as errors, e.g:

> * For target support_native_java.desktop_libfontmanager_hb-ot-shape-fallback.o:
> In file included from src/java.desktop/share/native/libharfbuzz/hb-ot-shape-fallback.cc:32:
> In file included from src/java.desktop/share/native/libharfbuzz/hb-kern.hh:32:
> src/java.desktop/share/native/libharfbuzz/hb-ot-layout-gpos-table.hh:1131:11: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
>       if (valueFormats[0].apply_value (c, this, &record->values[0], buffer->cur_pos()) |
>           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>                                                                                        ||
> src/java.desktop/share/native/libharfbuzz/hb-ot-layout-gpos-table.hh:1131:11: note: cast one or both operands to int to silence this warning
> src/java.desktop/share/native/libharfbuzz/hb-ot-layout-gpos-table.hh:1417:9: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
>       if (valueFormat1.apply_value (c, this, v, buffer->cur_pos()) |
>           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>                                                                    ||
> src/java.desktop/share/native/libharfbuzz/hb-ot-layout-gpos-table.hh:1417:9: note: cast one or both operands to int to silence this warning
> 2 errors generated.

The sources contain a comment: /* Note the intentional use of "|" instead of short-circuit "||". */ above line 1131 and 1417.

Casting one operand to int (as suggested in the warning text) does fix the issue (see attached patch).

A similar issue might exist in other openjdk ports when built on -CURRENT (not tested).
Comment 1 Martin MATO 2022-08-10 10:13:03 UTC
The patch proposed here worked flawlessly for me on a:
13.1-STABLE FreeBSD 13.1-STABLE #35 stable/13-n251972-fb8e858c69f: Thu Jul 28 10:03:51 CEST 2022

Thank you.
Comment 2 Jonathan Chen 2022-08-10 20:05:37 UTC
This bug also crops up with recent version of 13-STABLE.
Comment 3 commit-hook freebsd_committer freebsd_triage 2022-08-28 14:56:13 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=3d41392b6e049ff56d2abf91749a82573eb3198d

commit 3d41392b6e049ff56d2abf91749a82573eb3198d
Author:     Stefan Eßer <se@FreeBSD.org>
AuthorDate: 2022-08-28 14:40:46 +0000
Commit:     Stefan Eßer <se@FreeBSD.org>
CommitDate: 2022-08-28 14:54:31 +0000

    java/openjdk11: fix build on 13.1 and -CURRENT

    Recent LLVM versions issue warnings for "|" being used with boolean
    operands. Such operations exist in OpenJDK and the source lines are
    marked with comments to not use logical operations instead.

    This breaks the build on 13.1 and -CURRENT when building with LLVM-13
    or newer due to the -Werror option being passed to the compiler.

    Fix this issue by casting one of the boolean operands to int, as
    suggested by the compiler in the error message for the case that the
    "|" operation should actually be used on purpose.

    I had submitted this patch as an attachment to PR 265687 on
    2022-08-07, but it has been ignored by the maintainer (java team).

    PR:             265687
    Approved by:    portmgr (implicit)

 ...tive_libharfbuzz_hb-ot-layout-gpos-table.hh (new) | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
Comment 4 Vladimir Druzenko freebsd_committer freebsd_triage 2022-12-11 14:41:22 UTC
Fixed? Close this?