This is the mail archive of the gcc@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: g++4.0 diagnostic on casting a static const member initializer to a double


On Mon, Jan 31, 2005 at 10:38:22AM -0800, Mark Mitchell wrote:

> Jonathan Wakely wrote:
> 
> >There seems to be a (possibly undocumented) GCC extension involved here.
> 
> Yes, I think that extension is undocumented, but intentional.  (That is 
> of course a bug in the documentation.)  The extension pre-dates my 
> involvement with G++, IIRC.

The diagnostic message was added when fixing c++/14550, but I don't
know if that was what changed the behaviour or if that had always been
there.

> That explains the diagnostic, too: it talks about the intializer 
> because, from a GNU-C++ point-of-view, the data member declaration 
> itself is OK.

Yes. If you compile with -pedantic you get the diagnostic Matt was
expecting.

*but* this is allowed, even with -pedantic and -pedantic-errors:

  struct S
  {
    static const int scd = 24.2;
  };

$ g++4x int.cc -c  -pedantic -pedantic-errors -std=c++98
int.cc:3: warning: converting to 'int' from 'double'
          ^^^^^^^
A strict reading of the standard says that conversion shouldn't be
allowed, so surely it should be an error with -pedantic-errors ?

jon

-- 
"A woman drove me to drink, I never had the courtesy to thank her."
	- W.C. Fields


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