This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [4.5 patch] allow d or D suffix for double for c/39027
On Tue, 24 Feb 2009, Janis Johnson wrote:
> I've noticed that constant suffixes that are extensions, such as 'i',
> are not rejected for -std=c99, only for -pedantic-errors; is that
> expected?
Yes, that is expected; the function of -std options such as that is to
ensure that valid programs are accepted with the correct semantics, while
-pedantic/-pedantic-errors are to ensure that invalid programs are
rejected.
Since a constant with a suffix such as 'i' is still a preprocessing number
in C99 (but one that it's invalid to convert from a preprocessing token to
a token), they can't lead to giving different semantics to a valid
program, just to accepting invalid programs, so it's appropriate for
-pedantic to determine whether they are diagnosed. The introduction of
hex floats in C99 was different because it changed the definition of
preprocessing numbers to allow "p+" and "p-" sequences, meaning some valid
programs changed semantics (e.g. gcc.dg/c90-hexfloat-2.c) so in that case
appropriate -std options do disable accepting some such numbers
altogether, even without -pedantic, to ensure that valid programs are
accepted. The same issue of changing the lexing rules applies to other
cases such as u"" strings.
--
Joseph S. Myers
joseph@codesourcery.com