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: Warnings on long constants in gcc 3.3, 3.4

On Tue, Jul 13, 2004 at 04:57:11PM +0000, Joseph S. Myers wrote:
> On Tue, 13 Jul 2004, Eric Sandeen wrote:
> > While I could append "LL" to the constant (with apparently some
> > portability problems for the MSVC compiler, argh), it has been stated to
> > me that c99 should promote the type of the constant to something that it
> > will fit into.
> Compile in C99 mode (-std=c99 or -std=gnu99) to get the C99 integer
> constant type rules, which were implemented in 3.3 but not in previous
> releases; then you won't get the warning.  This isn't the default yet
> since substantial parts of C99 are unimplemented.

I was only going to bring this up when I had time to finish my patch (changing
one line of code in GCC seems to involve a lot of work <g>), but this solution
doesn't work for C++. One could easily argue that as the long long type doesn't
exist in C++ right now, it's not valid, but given that it historically (<3.3)
the usage of the OP has been usable in C++ as well, that seems bad. In
particlar, as the OP mentioned, a lot of Windows compilers don't like LL, but
have no problem with a 64-bit constant that has no suffix at all.

My proposed fix was to have -Wno-long-long disable this warning (actually an
error in C++), which will work for both C and C++. It's on by default
(regardless of the settings of -Wall/-Wextra), so random users who added an
extra hex digit onto their int constant (or whatever) would not be affected.
Some discussion on this is in PR/13358.

Any comments on this solution? Good idea? Bad idea? If I don't get flamed down
too hard, maybe I'll take a shot at finishing up the docs and tests later this


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