This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [jsm28@cam.ac.uk: c/945: Preprocessor errors for long long integer constants under wrong conditions]
- To: Neil Booth <neilb at earthling dot net>
- Subject: Re: [jsm28@cam.ac.uk: c/945: Preprocessor errors for long long integer constants under wrong conditions]
- From: "Zack Weinberg" <zackw at Stanford dot EDU>
- Date: Fri, 1 Dec 2000 15:19:40 -0800
- Cc: gcc at gcc dot gnu dot org
- References: <20001201222652.A9905@daikokuya.demon.co.uk>
On Fri, Dec 01, 2000 at 10:26:52PM +0000, Neil Booth wrote:
> ----- Forwarded message from Joseph Myers <jsm28@cam.ac.uk> -----
>
> GCC gives preprocessor errors for the use of LL-suffixed integer
> constants in #if expressions under the wrong conditions. The correct
> rules, following the definitions of the relevant command line options,
> are:
>
> * -std=c89 or -std=gnu89 without -pedantic, accept silently.
> * -std=c89 or -std=gnu89 with -pedantic, warning (not error).
> * -std=c89 or -std=gnu89 with -pedantic-errors, error.
>
> * -std=iso9899:199409, as -std=c89.
>
> * C99 mode, accept regardless of pedantic setting.
>
> -----
>
> Zack, do you agree with Joseph's analysis here? In particular, that
>
> a) He is treating gnu89 the same as c89
> b) c89 accepts LL silently in the normal case.
I pretty much agree with Joseph, but the docs are not terribly clear,
so I'm opening this up to the whole list for opinions.
Here's how I read it: The difference between -std=cXX and -std=gnuXX
is that the former suppresses extensions. *Which* extensions get
suppressed is not well defined. It has to turn off all extensions
that alter the behavior of a s.c. program; we also turn off many
others.
-pedantic enables mandatory diagnostics which are likely to trigger
false positives in casual C (e.g. code which doesn't take great care
over signed vs. unsigned char).
A C89 program that contains 1234LL is ill-formed (invalid phase 6
token), and therefore receives a mandatory diagnostic. However,
giving it a meaning is an extension which does not alter any
s.c. program, so it need not be suppressed by -std=cXX (x < 99).
So we have three consistent choices as I see it:
1. Disable long long constants under -std=c(89|95). To be completely
consistent, we should also disable all other instances of long
long. Then an occurrence of 1234LL would of course provoke a hard
error wherever it appeared.
2. Continue to accept long long constants under -std=c(89|95), but
deliver a warning. This warning should be made into an error by
-pedantic-errors.
3. Same as 2, but the warning is only given with -pedantic.
Given that these constants are likely to appear in system headers, I'd
personally vote for option 3, which appears to be Joseph's preferred
option as well.
I'd like to see all the effects of the various -std switches and
-pedantic thoroughly documented.
zw