This is the mail archive of the gcc-patches@gcc.gnu.org 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 Mon, May 11, 2015 at 05:09:26PM +0200, Manuel López-Ibáñez wrote:
> On 11/05/15 16:21, Marek Polacek wrote:
> >The -Wshift-negative-value patch caused grief since it breaks building
> >some programs.  The following patch should alleviate the pain a bit: mark
> >a left shift of a negative value as non-const only if pedantic.
> 
> Either this is not correct according to the guidelines ("the flag pedantic
> should not cause generated code differences or errors",
> https://gcc.gnu.org/wiki/DiagnosticsGuidelines) or the guidelines need
> updating.
[...]

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").

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.

	Marek


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