This is the mail archive of the
mailing list for the GCC project.
Re: C++ PATCH: Disallow floating-point literals in integral-constant expressions
- From: Jonathan Wakely <cow at compsoc dot man dot ac dot uk>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org
- Date: Tue, 1 Feb 2005 17:46:24 +0000
- Subject: Re: C++ PATCH: Disallow floating-point literals in integral-constant expressions
- References: <200502010102.j1112IsD021436@sethra.codesourcery.com>
On Mon, Jan 31, 2005 at 05:02:18PM -0800, Mark Mitchell wrote:
> The standard says that floating-point literals are only allowed in
> integral constant expressions if they are immediately cast to an
> integral or enumeration type. When I implemented checks for integral
> constant-expressions, I failed to check this case. Remedied with the
> attached patch.
Was this patch supposed to prevent the case I pointed out?
static const int scd = 24.0;
$ g++4x int3.cc -c -pedantic -pedantic-errors
int3.cc:3: warning: converting to 'int' from 'double'
This illegal code only raises a warning, even with -pedantic-errors
and/or -Werror. The warning can be silenced with -w.
This code gives a warning (not an error) in every version of GCC I
have available to test, but that doesn't make it right.
Should I file a PR to track it ?
"It is unbecoming for young men to utter maxims."