On 11 May 2015 at 17:54, Marek Polacek <pola...@redhat.com> 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):
https://gcc.gnu.org/ml/gcc/2013-11/msg00253.html

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 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19976#c7) and
the solution was to delay folding
(https://gcc.gnu.org/ml/gcc-patches/2008-10/msg01061.html).

> 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
https://gcc.gnu.org/ml/gcc-patches/2008-10/msg01061.html and
https://gcc.gnu.org/ml/gcc/2013-11/msg00253.html about to fix this
properly. */

Cheers,

Manuel.

Reply via email to