clang: & precedence

Torbjorn Granlund tg at
Sat Nov 30 11:15:33 UTC 2013

Thomas Klausner <wiz at> writes:

  NetBSD currently contains in its source tree gmp-5.1.3 (for compiling
  gcc, also included) and clang (as alternative compiler). Either gcc or
  clang can be chosen to compile the whole system (at least on x86_64
  and a few other platforms).
  gmp-5.1.3 does not compile with clang-3.4rc1 (r195771) with the
  default compilation flags used in the NetBSD build infrastructure.
  The first error is:
  --- toom44_mul.o ---
  /archive/foreign/src/external/lgpl3/gmp/lib/libgmp/../../dist/mpn/generic/toom44_mul.c:209:52: error: '&' within '|' [-Werror,-Wbitwise-op-parentheses]
    flags = (enum toom7_flags) (flags | toom7_w3_neg & mpn_toom_eval_dgr3_pm1 (apx, amx, ap, n, s, tp));
                                      ~ ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /archive/foreign/src/external/lgpl3/gmp/lib/libgmp/../../dist/mpn/generic/toom44_mul.c:209:52: note: place parentheses around the '&' expression to silence this warning
    flags = (enum toom7_flags) (flags | toom7_w3_neg & mpn_toom_eval_dgr3_pm1 (apx, amx, ap, n, s, tp));
  I fixed this by adding parentheses around the & part (after testing
  that this binds stronger than | in gcc) and tried again, and had
  similar failures in the next files:
  I checked the gmp hg repo yesterday and this code is unchanged in the
  latest versions of the three files.
GMP is written in the C language.  It seems that that compiler (at least
under some special flags) does not accept C.

  Before I start working on this, I'd like to know if I start adding
  parentheses and send them to you, will they be accepted?
  If not, what do you suggest?
Fix clang to accept C, or suppress flags that makes it only accept a
subset of the C language?

Please encrypt, key id 0xC8601622

"A week in the lab saves an hour in the library."

More information about the gmp-bugs mailing list