C++ PATCH: Disallow floating-point literals in integral-constant expressions
Jonathan Wakely
cow@compsoc.man.ac.uk
Tue Feb 1 17:46:00 GMT 2005
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.
Hi Mark,
Was this patch supposed to prevent the case I pointed out?
struct S
{
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 ?
jon
--
"It is unbecoming for young men to utter maxims."
- Aristotle
More information about the Libstdc++
mailing list