This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C PATCH for -Wshift-negative-value (PR c/66066)

On 11 May 2015 at 17:54, Marek Polacek <> wrote:
> The problem here isn't in the -Wshift-negative-value warning itself; the
> problem is with marking -1 << 0 as a non-constant: later on, we warn in
> a context where a constant expression is needed ("initializer element is
> not a constant expression"), and for e.g. int foo = -1 << 0 | 9; there's
> an error ("initializer element is not constant").

Yes, I understand. What I'm saying is that if folding was done at the
moment that the constant is requested, this would be a case of
pedwarn-if-pedantic, which is exactly what Joseph is discussing here
for case (b):

It doesn't matter that the error "initializer element is not a
constant expression" is not given as long as an error (e.g., "left
shift of negative value is undefined according to ISO C99") is given
with -pedantic-errors.

I'm sorry to sound so "pedantic" but we have faced this same issue in
the past ( and
the solution was to delay folding

> My change means that we wouldn't complain unless -pedantic (to not upset
> too many users).  I'm not particularly fond of it, but it seems like the
> simplest solution.

-Wpedantic (which is the same as -pedantic) should not give errors.
Otherwise, it would mean that someone who uses -Wpedantic-
-Wno-pedantic will silence the error, but someone that uses
-Werror=pedantic -Wno-error=pedantic will still see an error (!).
There is also no way to tell that error is related to -Wpedantic.

But if this is the accepted solution, please at least test
global_dc->pedantic_errors instead and put a big /* ???? This is a
hack to reject non-conforming programs with -pedantic-errors and
accept them otherwise. See and about to fix this
properly. */



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]