This is the mail archive of the gcc-patches@gcc.gnu.org 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: C++ PATCH: Disallow floating-point literals in integral-constant expressions


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


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