public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11393] New: Initializer of static const float class member is not legal in c++98
@ 2003-07-01 17:25 rearnsha at gcc dot gnu dot org
  2003-07-01 17:31 ` [Bug c++/11393] " pinskia at physics dot uc dot edu
                   ` (18 more replies)
  0 siblings, 19 replies; 34+ messages in thread
From: rearnsha at gcc dot gnu dot org @ 2003-07-01 17:25 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393

           Summary: Initializer of static const float class member is not
                    legal in c++98
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rearnsha at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: any

The following code is not legal in c++ 98 (9.4.2 par 4) and should generate a
diagnostic.  As this is probably a gnu extension, it should probably only do
this when -std=c++98.

g++ -std=c++98 foo.cc

class A {  // OK
 static const int a = 1;     
};

class B {  // Not legal
 static const float pi = 3.1415926;
};


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
  2003-07-01 17:25 [Bug c++/11393] New: Initializer of static const float class member is not legal in c++98 rearnsha at gcc dot gnu dot org
@ 2003-07-01 17:31 ` pinskia at physics dot uc dot edu
  2003-07-02 16:43 ` rearnsha at gcc dot gnu dot org
                   ` (17 subsequent siblings)
  18 siblings, 0 replies; 34+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-07-01 17:31 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393


pinskia at physics dot uc dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


------- Additional Comments From pinskia at physics dot uc dot edu  2003-07-01 17:31 -------
It does reject with "gcc -S pr11393.cc -pedantic-errors" in the mainline (20030701) and has done 
since at least 2.95.3.

I think this is the right thing to do is to warn about with -pedantic.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
  2003-07-01 17:25 [Bug c++/11393] New: Initializer of static const float class member is not legal in c++98 rearnsha at gcc dot gnu dot org
  2003-07-01 17:31 ` [Bug c++/11393] " pinskia at physics dot uc dot edu
@ 2003-07-02 16:43 ` rearnsha at gcc dot gnu dot org
  2003-07-02 16:47 ` pinskia at physics dot uc dot edu
                   ` (16 subsequent siblings)
  18 siblings, 0 replies; 34+ messages in thread
From: rearnsha at gcc dot gnu dot org @ 2003-07-02 16:43 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393



------- Additional Comments From rearnsha at gcc dot gnu dot org  2003-07-02 16:43 -------
So why doesn't -std=c++98 generate such a warning.  I still consider 
failure to do that a bug.  If I wanted GNU extensions I wouldn't be 
using -std.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
  2003-07-01 17:25 [Bug c++/11393] New: Initializer of static const float class member is not legal in c++98 rearnsha at gcc dot gnu dot org
  2003-07-01 17:31 ` [Bug c++/11393] " pinskia at physics dot uc dot edu
  2003-07-02 16:43 ` rearnsha at gcc dot gnu dot org
@ 2003-07-02 16:47 ` pinskia at physics dot uc dot edu
  2003-07-02 17:06 ` rearnsha at arm dot com
                   ` (15 subsequent siblings)
  18 siblings, 0 replies; 34+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-07-02 16:47 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393



------- Additional Comments From pinskia at physics dot uc dot edu  2003-07-02 16:47 -------
Subject: Re:  Initializer of static const float class member is not legal in c++98

 From <http://gcc.gnu.org/onlinedocs/gcc/Standards.html>:
To select this standard in GCC, use one of the options -ansi, -std=c89 
or -std=iso9899:1990; to obtain all the diagnostics required by the 
standard, you should also specify -pedantic (or -pedantic-errors if you 
want them to be errors rather than warnings).  See Options Controlling 
C Dialect


Thanks,
Andrew Pinski

On Wednesday, Jul 2, 2003, at 12:43 US/Eastern, rearnsha at gcc dot gnu 
dot org wrote:

> PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* 
> gcc-bugs@gcc.gnu.org.
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393
>
>
>
> ------- Additional Comments From rearnsha at gcc dot gnu dot org  
> 2003-07-02 16:43 -------
> So why doesn't -std=c++98 generate such a warning.  I still consider
> failure to do that a bug.  If I wanted GNU extensions I wouldn't be
> using -std.
>
>


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
  2003-07-01 17:25 [Bug c++/11393] New: Initializer of static const float class member is not legal in c++98 rearnsha at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2003-07-02 16:47 ` pinskia at physics dot uc dot edu
@ 2003-07-02 17:06 ` rearnsha at arm dot com
  2003-07-02 23:28 ` jsm28 at cam dot ac dot uk
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 34+ messages in thread
From: rearnsha at arm dot com @ 2003-07-02 17:06 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393



------- Additional Comments From rearnsha at arm dot com  2003-07-02 17:06 -------
Subject: Re:  Initializer of static const float class 
 member is not legal in c++98

> PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393
> 
> 
> 
> ------- Additional Comments From pinskia at physics dot uc dot edu  2003-07-02 16:47 -------
> Subject: Re:  Initializer of static const float class member is not legal in c++98
> 
>  From <http://gcc.gnu.org/onlinedocs/gcc/Standards.html>:
> To select this standard in GCC, use one of the options -ansi, -std=c89 
> or -std=iso9899:1990; to obtain all the diagnostics required by the 
> standard, you should also specify -pedantic (or -pedantic-errors if you 
> want them to be errors rather than warnings).  See Options Controlling 
> C Dialect
> 

Well, for starters C++ isn't a C dialect.  For seconds, it really doesn't 
make sense to me that, given I can type

	-std=gnu89

to get GNU extensions,

	-std=c89 

doesn't give me (at the very least) warnings about GNU extensions.  Why 
have the option at all?

We should just make the compiler use gnu89 (or gnu99, or whatever) as the 
default, and have -std=c89 *mean* c89 code not something else.

Even more perverse is that 

	-std=gnu89 -pedantic

gives me warnings about ISO-isms.

R.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
  2003-07-01 17:25 [Bug c++/11393] New: Initializer of static const float class member is not legal in c++98 rearnsha at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2003-07-02 17:06 ` rearnsha at arm dot com
@ 2003-07-02 23:28 ` jsm28 at cam dot ac dot uk
  2003-07-04 11:10 ` [Bug c++/11393] New: " Gabriel Dos Reis
                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 34+ messages in thread
From: jsm28 at cam dot ac dot uk @ 2003-07-02 23:28 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393



------- Additional Comments From jsm28 at cam dot ac dot uk  2003-07-02 23:28 -------
Subject: Re:  Initializer of static const float class member
 is not legal in c++98

On Wed, 2 Jul 2003, rearnsha at arm dot com wrote:

> to get GNU extensions,
> 
> 	-std=c89 
> 
> doesn't give me (at the very least) warnings about GNU extensions.  Why 
> have the option at all?

To accept all code the standard requires us to accept, with the standard
semantics (e.g., enabling trigraphs).

> We should just make the compiler use gnu89 (or gnu99, or whatever) as the 
> default, and have -std=c89 *mean* c89 code not something else.

You mean have the -std options imply -pedantic?  I think that would be
reasonable, to reduce the length of the invocation required for a standard
mode.  (And if we *don't* allow -ansi -no-pedantic to turn the warnings
off again then this would also fix or at least hide a few bugs where
standard code is only accepted with -pedantic.)

> Even more perverse is that 
> 
> 	-std=gnu89 -pedantic
> 
> gives me warnings about ISO-isms.

That is the combination used (implicitly) in GCC bootstrap, with -pedantic
to warn about nonportable usages in GCC but without needing to mess with
feature test macros (which -std=c89 would imply, since it also puts the
headers into standards mode).

The manual explains the concept of "base standard" behind the warnings in
such cases.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
  2003-07-01 17:25 [Bug c++/11393] New: Initializer of static const float class member is not legal in c++98 rearnsha at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2003-07-04 11:10 ` [Bug c++/11393] New: " Gabriel Dos Reis
@ 2003-07-04 11:10 ` gdr at integrable-solutions dot net
  2003-07-04 11:33 ` gdr at integrable-solutions dot net
                   ` (11 subsequent siblings)
  18 siblings, 0 replies; 34+ messages in thread
From: gdr at integrable-solutions dot net @ 2003-07-04 11:10 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393



------- Additional Comments From gdr at integrable-solutions dot net  2003-07-04 11:10 -------
Subject: Re:  New: Initializer of static const float class member is not legal in c++98

"rearnsha at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
| 
| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393
| 
|            Summary: Initializer of static const float class member is not
|                     legal in c++98
|            Product: gcc
|            Version: 3.4
|             Status: UNCONFIRMED
|           Keywords: accepts-invalid
|           Severity: normal
|           Priority: P2
|          Component: c++
|         AssignedTo: unassigned at gcc dot gnu dot org
|         ReportedBy: rearnsha at gcc dot gnu dot org
|                 CC: gcc-bugs at gcc dot gnu dot org
|  GCC build triplet: any
| 
| The following code is not legal in c++ 98 (9.4.2 par 4) and should generate a
| diagnostic.  As this is probably a gnu extension, it should probably only do
| this when -std=c++98.

I think that was even removed in 3.4, so we should definitely error
(or pedwarn) that construct.

-- Gaby


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Bug c++/11393] New: Initializer of static const float class member is not legal in c++98
  2003-07-01 17:25 [Bug c++/11393] New: Initializer of static const float class member is not legal in c++98 rearnsha at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2003-07-02 23:28 ` jsm28 at cam dot ac dot uk
@ 2003-07-04 11:10 ` Gabriel Dos Reis
  2003-07-04 11:10 ` [Bug c++/11393] " gdr at integrable-solutions dot net
                   ` (12 subsequent siblings)
  18 siblings, 0 replies; 34+ messages in thread
From: Gabriel Dos Reis @ 2003-07-04 11:10 UTC (permalink / raw)
  To: gcc-bugzilla; +Cc: gcc-bugs

"rearnsha at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
| 
| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393
| 
|            Summary: Initializer of static const float class member is not
|                     legal in c++98
|            Product: gcc
|            Version: 3.4
|             Status: UNCONFIRMED
|           Keywords: accepts-invalid
|           Severity: normal
|           Priority: P2
|          Component: c++
|         AssignedTo: unassigned at gcc dot gnu dot org
|         ReportedBy: rearnsha at gcc dot gnu dot org
|                 CC: gcc-bugs at gcc dot gnu dot org
|  GCC build triplet: any
| 
| The following code is not legal in c++ 98 (9.4.2 par 4) and should generate a
| diagnostic.  As this is probably a gnu extension, it should probably only do
| this when -std=c++98.

I think that was even removed in 3.4, so we should definitely error
(or pedwarn) that construct.

-- Gaby


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
  2003-07-01 17:25 [Bug c++/11393] New: Initializer of static const float class member is not legal in c++98 rearnsha at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2003-07-04 11:10 ` [Bug c++/11393] " gdr at integrable-solutions dot net
@ 2003-07-04 11:33 ` gdr at integrable-solutions dot net
  2003-07-04 11:33 ` gdr at integrable-solutions dot net
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 34+ messages in thread
From: gdr at integrable-solutions dot net @ 2003-07-04 11:33 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393



------- Additional Comments From gdr at integrable-solutions dot net  2003-07-04 11:33 -------
Subject: Re:  Initializer of static const float class member is not legal in c++98

"pinskia at physics dot uc dot edu" <gcc-bugzilla@gcc.gnu.org> writes:
| It does reject with "gcc -S pr11393.cc -pedantic-errors" in the mainline (20030701) and has done 
| since at least 2.95.3.

that is because, we actively removed that undocumented extension from
mainline. 

-- Gaby


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
  2003-07-01 17:25 [Bug c++/11393] New: Initializer of static const float class member is not legal in c++98 rearnsha at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2003-07-04 11:33 ` gdr at integrable-solutions dot net
@ 2003-07-04 11:33 ` gdr at integrable-solutions dot net
  2003-07-04 11:35 ` gdr at integrable-solutions dot net
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 34+ messages in thread
From: gdr at integrable-solutions dot net @ 2003-07-04 11:33 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393



------- Additional Comments From gdr at integrable-solutions dot net  2003-07-04 11:33 -------
Subject: Re:  Initializer of static const float class member is not legal in c++98

"rearnsha at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
| 
| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393
| 
| 
| 
| ------- Additional Comments From rearnsha at gcc dot gnu dot org  2003-07-02 16:43 -------
| So why doesn't -std=c++98 generate such a warning.  I still consider 
| failure to do that a bug. 

Yes, it is a bug.

-- Gaby


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
  2003-07-01 17:25 [Bug c++/11393] New: Initializer of static const float class member is not legal in c++98 rearnsha at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2003-07-04 11:33 ` gdr at integrable-solutions dot net
@ 2003-07-04 11:35 ` gdr at integrable-solutions dot net
  2003-07-07 10:25 ` rearnsha at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  18 siblings, 0 replies; 34+ messages in thread
From: gdr at integrable-solutions dot net @ 2003-07-04 11:35 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393



------- Additional Comments From gdr at integrable-solutions dot net  2003-07-04 11:35 -------
Subject: Re:  Initializer of static const float class member is not legal in c++98

"jsm28 at cam dot ac dot uk" <gcc-bugzilla@gcc.gnu.org> writes:

| The manual explains the concept of "base standard" behind the warnings in
| such cases.

The manual explains the "logic" behing those things, but the logic
behind those things is broken.

-- Gaby


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
  2003-07-01 17:25 [Bug c++/11393] New: Initializer of static const float class member is not legal in c++98 rearnsha at gcc dot gnu dot org
                   ` (10 preceding siblings ...)
  2003-07-07 10:25 ` rearnsha at gcc dot gnu dot org
@ 2003-07-07 10:25 ` rearnsha at gcc dot gnu dot org
  2003-07-07 23:23 ` bangerth at dealii dot org
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 34+ messages in thread
From: rearnsha at gcc dot gnu dot org @ 2003-07-07 10:25 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393


rearnsha at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|CLOSED                      |UNCONFIRMED
         Resolution|INVALID                     |


------- Additional Comments From rearnsha at gcc dot gnu dot org  2003-07-07 10:25 -------
It doesn't seem appropriate that this bug should be closed without comment from
one of the C++ front-end maintainers.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
  2003-07-01 17:25 [Bug c++/11393] New: Initializer of static const float class member is not legal in c++98 rearnsha at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2003-07-04 11:35 ` gdr at integrable-solutions dot net
@ 2003-07-07 10:25 ` rearnsha at gcc dot gnu dot org
  2003-07-07 10:25 ` rearnsha at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 34+ messages in thread
From: rearnsha at gcc dot gnu dot org @ 2003-07-07 10:25 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393


rearnsha at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |CLOSED


------- Additional Comments From rearnsha at gcc dot gnu dot org  2003-07-07 10:25 -------
It doesn't seem appropriate that this bug should be closed without comment from
one of the C++ front-end maintainers.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
  2003-07-01 17:25 [Bug c++/11393] New: Initializer of static const float class member is not legal in c++98 rearnsha at gcc dot gnu dot org
                   ` (11 preceding siblings ...)
  2003-07-07 10:25 ` rearnsha at gcc dot gnu dot org
@ 2003-07-07 23:23 ` bangerth at dealii dot org
  2003-08-11 15:32 ` lerdsuwa at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 34+ messages in thread
From: bangerth at dealii dot org @ 2003-07-07 23:23 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393



------- Additional Comments From bangerth at dealii dot org  2003-07-07 23:23 -------
I certainly concur. The interaction of the flags -std, -ansi, -pedantic is
not at all clear to me, and it would be good if either their relative
meaning if one of the other flags is given, is explained in detail, or
if they are meant to represent orthogonal concepts. One of the questions
here is: does -std=XX define a minimal or a maximal set of things gcc
has to support, as viewed in the presence of gcc extensions?

W.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
  2003-07-01 17:25 [Bug c++/11393] New: Initializer of static const float class member is not legal in c++98 rearnsha at gcc dot gnu dot org
                   ` (12 preceding siblings ...)
  2003-07-07 23:23 ` bangerth at dealii dot org
@ 2003-08-11 15:32 ` lerdsuwa at gcc dot gnu dot org
  2003-08-23  0:39 ` dhazeghi at yahoo dot com
                   ` (4 subsequent siblings)
  18 siblings, 0 replies; 34+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2003-08-11 15:32 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393


lerdsuwa at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2003-08-11 15:32:40
               date|                            |


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
  2003-07-01 17:25 [Bug c++/11393] New: Initializer of static const float class member is not legal in c++98 rearnsha at gcc dot gnu dot org
                   ` (13 preceding siblings ...)
  2003-08-11 15:32 ` lerdsuwa at gcc dot gnu dot org
@ 2003-08-23  0:39 ` dhazeghi at yahoo dot com
  2004-11-09 23:09 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 34+ messages in thread
From: dhazeghi at yahoo dot com @ 2003-08-23  0:39 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393


dhazeghi at yahoo dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4                         |---


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
  2003-07-01 17:25 [Bug c++/11393] New: Initializer of static const float class member is not legal in c++98 rearnsha at gcc dot gnu dot org
                   ` (14 preceding siblings ...)
  2003-08-23  0:39 ` dhazeghi at yahoo dot com
@ 2004-11-09 23:09 ` pinskia at gcc dot gnu dot org
  2005-04-18 17:32 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  18 siblings, 0 replies; 34+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-09 23:09 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-09 23:09 -------
*** Bug 18409 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rnewman at compubrite dot
                   |                            |com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
  2003-07-01 17:25 [Bug c++/11393] New: Initializer of static const float class member is not legal in c++98 rearnsha at gcc dot gnu dot org
                   ` (15 preceding siblings ...)
  2004-11-09 23:09 ` pinskia at gcc dot gnu dot org
@ 2005-04-18 17:32 ` pinskia at gcc dot gnu dot org
  2005-04-18 17:38 ` pinskia at gcc dot gnu dot org
  2005-05-10 17:44 ` pinskia at gcc dot gnu dot org
  18 siblings, 0 replies; 34+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-18 17:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-04-18 17:32 -------
*** Bug 21089 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |matz at suse dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
  2003-07-01 17:25 [Bug c++/11393] New: Initializer of static const float class member is not legal in c++98 rearnsha at gcc dot gnu dot org
                   ` (16 preceding siblings ...)
  2005-04-18 17:32 ` pinskia at gcc dot gnu dot org
@ 2005-04-18 17:38 ` pinskia at gcc dot gnu dot org
  2005-05-10 17:44 ` pinskia at gcc dot gnu dot org
  18 siblings, 0 replies; 34+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-18 17:38 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-04-18 17:38 -------
This is a documented deprecated feature:
http://gcc.gnu.org/onlinedocs/gcc/Deprecated-Features.html#Deprecated-Features
G++ allows static data members of const floating-point type to be declared with an initializer in a class 
definition. The standard only allows initializers for static members of const integral types and const 
enumeration types so this extension has been deprecated and will be removed from a future version.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
  2003-07-01 17:25 [Bug c++/11393] New: Initializer of static const float class member is not legal in c++98 rearnsha at gcc dot gnu dot org
                   ` (17 preceding siblings ...)
  2005-04-18 17:38 ` pinskia at gcc dot gnu dot org
@ 2005-05-10 17:44 ` pinskia at gcc dot gnu dot org
  18 siblings, 0 replies; 34+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-10 17:44 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-05-10 17:44 -------
*** Bug 21499 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |papadopo at shfj dot cea dot
                   |                            |fr


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
       [not found] <bug-11393-4@http.gcc.gnu.org/bugzilla/>
                   ` (11 preceding siblings ...)
  2012-10-26 11:44 ` paolo.carlini at oracle dot com
@ 2012-10-26 11:45 ` manu at gcc dot gnu.org
  12 siblings, 0 replies; 34+ messages in thread
From: manu at gcc dot gnu.org @ 2012-10-26 11:45 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393

--- Comment #30 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-26 11:45:11 UTC ---
> 
> Your "c" example seems like a completely separate issue that should be a
> separate PR, I don't understand why it's being discussed here.

It is now PR55080.

About this PR, I concur now with Jonathan:

"My suggestion would be do nothing and lose the PR.  If you want a warning in
C++98 use -pedantic, which is consistent with other GNU extensions. In C++11
use constexpr."


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
       [not found] <bug-11393-4@http.gcc.gnu.org/bugzilla/>
                   ` (10 preceding siblings ...)
  2012-10-26  2:13 ` redi at gcc dot gnu.org
@ 2012-10-26 11:44 ` paolo.carlini at oracle dot com
  2012-10-26 11:45 ` manu at gcc dot gnu.org
  12 siblings, 0 replies; 34+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-26 11:44 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |MOVED

--- Comment #29 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-26 11:43:52 UTC ---
Ok, thanks guys. Let's close this then, the new clearer PRs clarify the valid
standing issues in this area.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
       [not found] <bug-11393-4@http.gcc.gnu.org/bugzilla/>
                   ` (9 preceding siblings ...)
  2012-10-26  2:05 ` manu at gcc dot gnu.org
@ 2012-10-26  2:13 ` redi at gcc dot gnu.org
  2012-10-26 11:44 ` paolo.carlini at oracle dot com
  2012-10-26 11:45 ` manu at gcc dot gnu.org
  12 siblings, 0 replies; 34+ messages in thread
From: redi at gcc dot gnu.org @ 2012-10-26  2:13 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393

--- Comment #28 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-10-26 02:13:23 UTC ---
(In reply to comment #27)
> And for similar reasons, it seems wrong to reject "b" with a permerror: The
> code is accepted in c++98 as an extension, so it could be equally accepted in
> c++11 as an extension, and warned by -pedantic. No need to force users to use
> constexpr

Why not?

C++11 offers a portable alternative, there is no reason to use a deprecated
extension when you can use constexpr.  It's an extension in C++98 because there
is no other way to write the code.  Supporting the extension in C++11 is wrong,
the portable, standard feature should be used instead.

> Again, this is what clang does, which makes perfect sense to me.

I guess clang supports it for GCC compatibility, not because it's a good idea
that we should copy.

> So, I still see two bugs.

Your "c" example seems like a completely separate issue that should be a
separate PR, I don't understand why it's being discussed here.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
       [not found] <bug-11393-4@http.gcc.gnu.org/bugzilla/>
                   ` (8 preceding siblings ...)
  2012-10-26  1:54 ` manu at gcc dot gnu.org
@ 2012-10-26  2:05 ` manu at gcc dot gnu.org
  2012-10-26  2:13 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 34+ messages in thread
From: manu at gcc dot gnu.org @ 2012-10-26  2:05 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393

--- Comment #27 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-26 02:04:38 UTC ---
And for similar reasons, it seems wrong to reject "b" with a permerror: The
code is accepted in c++98 as an extension, so it could be equally accepted in
c++11 as an extension, and warned by -pedantic. No need to force users to use
constexpr or the hammer of -fpermissive for something that works in c++98.
Again, this is what clang does, which makes perfect sense to me.

So, I still see two bugs.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
       [not found] <bug-11393-4@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2012-10-26  1:12 ` redi at gcc dot gnu.org
@ 2012-10-26  1:54 ` manu at gcc dot gnu.org
  2012-10-26  2:05 ` manu at gcc dot gnu.org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 34+ messages in thread
From: manu at gcc dot gnu.org @ 2012-10-26  1:54 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393

--- Comment #26 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-26 01:53:59 UTC ---
> (In reply to comment #24)
> > So, in g++ parlance, "b" and "d" is a pedwarn enabled by default, while "c" is
> > a pedwarn in c++98 mode enabled by -Wpedantic and nothing in c++11 mode.
> 
> Which makes sense, because "c" is not valid C++98 but is valid C++11
> 
> I think referring to what's actually valid according to the standard is useful,
> rather than inferring it from what other compilers do.
> 
> My suggestion would be do nothing and lose the PR.  If you want a warning in
> C++98 use -pedantic, which is consistent with other GNU extensions. In C++11
> use constexpr.

But -pedantic is creating an error, which is not what one would expect.

Moreover, it is creating an error for something that is accepted without
-pedantic and accepted by C++11, and has well-defined semantics, so it could be
perfectly accepted as a GNU extension (which is what clang does).

Anyway, I am not going to work on this, and I guess we scared Paolo, so someone
else would have to fix the above, if they care. But it is definitely a bug.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
       [not found] <bug-11393-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2012-10-26  0:24 ` manu at gcc dot gnu.org
@ 2012-10-26  1:12 ` redi at gcc dot gnu.org
  2012-10-26  1:54 ` manu at gcc dot gnu.org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 34+ messages in thread
From: redi at gcc dot gnu.org @ 2012-10-26  1:12 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393

--- Comment #25 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-10-26 01:12:24 UTC ---
(In reply to comment #19)
> since the initialization of "b" is anyway a deprecated feature (and a
> permerror in c++11), I would say: just make it a permerror also in c++98.

The problem with that is the lack of a good alternative. In C++11 there's a
workaround: use constexpr, but if you can't use C++11 then the extension is
useful, so removing it from C++98 mode would cause unnecessary annoyance for
users.


(In reply to comment #23)
> Do you mean floating-point literals or in-class initializer for static data
> member of type 'const float'?

The latter, which is the subject of this PR.

> In any case, clang seems to implement the most sane behaviour, no?
> 
> g++ should do exactly the same, that is, accept the code with a pedwarn about
> "b" (either enabled by default or conditional in -Wpedantic), and do not warn
> or give an error about "c".

No. "c" is not valid in C++98, just because clang doesn't diagnose it doesn't
mean GCC should copy that. Richard's original report is about accepting
non-standard code without complaint, let's not make that worse!


(In reply to comment #24)
> So, in g++ parlance, "b" and "d" is a pedwarn enabled by default, while "c" is
> a pedwarn in c++98 mode enabled by -Wpedantic and nothing in c++11 mode.

Which makes sense, because "c" is not valid C++98 but is valid C++11

I think referring to what's actually valid according to the standard is useful,
rather than inferring it from what other compilers do.

My suggestion would be do nothing and lose the PR.  If you want a warning in
C++98 use -pedantic, which is consistent with other GNU extensions. In C++11
use constexpr.

Making "b" give a pedwarn enabled by default would make some sense, but
probably still annoy some users.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
       [not found] <bug-11393-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2012-10-26  0:16 ` manu at gcc dot gnu.org
@ 2012-10-26  0:24 ` manu at gcc dot gnu.org
  2012-10-26  1:12 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 34+ messages in thread
From: manu at gcc dot gnu.org @ 2012-10-26  0:24 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393

--- Comment #24 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-26 00:23:46 UTC ---
Interestingly,

manuel@gcc10:~$ ~/bin/clang++ -std=c++98 pr11393.cc -pedantic-errors
pr11393.cc:3:21: error: in-class initializer for static data member of type
'const float' is a GNU extension [-Werror,-Wgnu]
 static const float b = 3;
                    ^   ~
pr11393.cc:4:23: warning: implicit conversion from 'double' to 'int' changes
value from 3.1415926 to 3 [-Wliteral-conversion]
 static const int c = 3.1415926;
                  ~   ^~~~~~~~~
pr11393.cc:4:23: error: in-class initializer for static data member is not a
constant expression; folding it to a constant is a GNU extension
[-Werror,-Wpedantic]
 static const int c = 3.1415926;
                      ^~~~~~~~~
pr11393.cc:5:21: error: in-class initializer for static data member of type
'const float' is a GNU extension [-Werror,-Wgnu]
 static const float d = 3.1415926;
                    ^   ~~~~~~~~~
1 warning and 3 errors generated.

So, in g++ parlance, "b" and "d" is a pedwarn enabled by default, while "c" is
a pedwarn in c++98 mode enabled by -Wpedantic and nothing in c++11 mode.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
       [not found] <bug-11393-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2012-10-26  0:02 ` redi at gcc dot gnu.org
@ 2012-10-26  0:16 ` manu at gcc dot gnu.org
  2012-10-26  0:24 ` manu at gcc dot gnu.org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 34+ messages in thread
From: manu at gcc dot gnu.org @ 2012-10-26  0:16 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393

--- Comment #23 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-26 00:16:00 UTC ---
(In reply to comment #22)
> (In reply to comment #21)
> > In my opinion, floating point literals are allowed in constant expressions in
> > the C++11 standard.
> 
> They're only valid with 'constexpr' which isn't used in the testcases in this
> PR  (and can't be in C++98)

Do you mean floating-point literals or in-class initializer for static data
member of type 'const float'?

In any case, clang seems to implement the most sane behaviour, no?

g++ should do exactly the same, that is, accept the code with a pedwarn about
"b" (either enabled by default or conditional in -Wpedantic), and do not warn
or give an error about "c".


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
       [not found] <bug-11393-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2012-10-25 23:49 ` rnewman at compubrite dot com
@ 2012-10-26  0:02 ` redi at gcc dot gnu.org
  2012-10-26  0:16 ` manu at gcc dot gnu.org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 34+ messages in thread
From: redi at gcc dot gnu.org @ 2012-10-26  0:02 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393

--- Comment #22 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-10-26 00:02:09 UTC ---
(In reply to comment #21)
> In my opinion, floating point literals are allowed in constant expressions in
> the C++11 standard.

They're only valid with 'constexpr' which isn't used in the testcases in this
PR  (and can't be in C++98)


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
       [not found] <bug-11393-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2012-10-25 23:44 ` manu at gcc dot gnu.org
@ 2012-10-25 23:49 ` rnewman at compubrite dot com
  2012-10-26  0:02 ` redi at gcc dot gnu.org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 34+ messages in thread
From: rnewman at compubrite dot com @ 2012-10-25 23:49 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393

--- Comment #21 from Rich Newman <rnewman at compubrite dot com> 2012-10-25 23:48:49 UTC ---
(In reply to comment #20)

The EDG front-end also accepts the code fragment from comment 19 without any
diagnostic message at all.

In my opinion, floating point literals are allowed in constant expressions in
the C++11 standard.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
       [not found] <bug-11393-4@http.gcc.gnu.org/bugzilla/>
  2012-10-25 22:41 ` paolo.carlini at oracle dot com
  2012-10-25 23:30 ` manu at gcc dot gnu.org
@ 2012-10-25 23:44 ` manu at gcc dot gnu.org
  2012-10-25 23:49 ` rnewman at compubrite dot com
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 34+ messages in thread
From: manu at gcc dot gnu.org @ 2012-10-25 23:44 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393

--- Comment #20 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-25 23:44:01 UTC ---
BTW, clang accepts "b" as a GNU extension, and it does not care at all about
"c" (except for the -Wconversion warning that is enabled by default).

manuel@gcc10:~$ ~/bin/clang++ -std=c++98 test.cc
test.cc:3:21: warning: in-class initializer for static data member of type
'const float' is a GNU extension [-Wgnu]
 static const float b = 3;
                    ^   ~
test.cc:4:23: warning: implicit conversion from 'double' to 'int' changes value
from 3.1415926 to 3 [-Wliteral-conversion]
 static const int c = 3.1415926;
                  ~   ^~~~~~~~~
2 warnings generated.
manuel@gcc10:~$ ~/bin/clang++ -std=c++11 test.cc
test.cc:3:21: warning: in-class initializer for static data member of type
'const float' is a GNU extension [-Wgnu]
 static const float b = 3;
                    ^   ~
test.cc:3:21: note: use 'constexpr' specifier to silence this warning
 static const float b = 3;
                    ^
 constexpr 
test.cc:4:23: warning: implicit conversion from 'double' to 'int' changes value
from 3.1415926 to 3 [-Wliteral-conversion]
 static const int c = 3.1415926;
                  ~   ^~~~~~~~~
2 warnings generated.

To be honest, I like infinitely more the behaviour of clang.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
       [not found] <bug-11393-4@http.gcc.gnu.org/bugzilla/>
  2012-10-25 22:41 ` paolo.carlini at oracle dot com
@ 2012-10-25 23:30 ` manu at gcc dot gnu.org
  2012-10-25 23:44 ` manu at gcc dot gnu.org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 34+ messages in thread
From: manu at gcc dot gnu.org @ 2012-10-25 23:30 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393

--- Comment #19 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-25 23:29:59 UTC ---
I think there are several issues conflated in this report. Perhaps the
following example is clearer:

class B { 
 static const int a = 1;     
 static const float b = 3;
 static const int c = 3.1415926;
};

Both -std=c++11 -pedantic and just -std=c++11 give:
error: ‘constexpr’ needed for in-class initialization of static data member
‘const float B::b’ of non-integral type [-fpermissive]
  static const float b = 3;
                         ^

-std=c++98 -pedantic gives
warning: ISO C++ forbids initialization of member constant ‘B::b’ of
non-integral type ‘const float’ [-Wpedantic]
  static const float b = 3;
                         ^
error: floating-point literal cannot appear in a constant-expression
  static const int c = 3.1415926;
                       ^

and -std=c++98 gives nothing.

Now, the first issue that Joseph discusses is that -std=, as currently
implemented, is not supposed to give all diagnostics required by the standard,
that is what -pedantic is for. Others disagree. Well, in this case, this issue
is moot, since the initialization of "b" is anyway a deprecated feature (and a
permerror in c++11), I would say: just make it a permerror also in c++98. Some
users may complain, but I think will make happy both Richard and Joseph.

The second bug I see here is that -pedantic creates a hard error for "c". This
is wrong. It is either a hard error all the time (with or without -pedantic) or
a permerror all the time, or it is a -pedantic warning that can be transformed
into an error by -pedantic-errors.

But there is probably even a third bug: are floating point literals accepted in
constant-expressions in c++11? If so, then the usual is to accept it in c++98
as an extension but warn with -pedantic (why reject something that is
implemented?). Otherwise, it should be rejected also in c++11.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
       [not found] <bug-11393-4@http.gcc.gnu.org/bugzilla/>
@ 2012-10-25 22:41 ` paolo.carlini at oracle dot com
  2012-10-25 23:30 ` manu at gcc dot gnu.org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 34+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-25 22:41 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|gcc-bugs at gcc dot gnu.org |manu at gcc dot gnu.org

--- Comment #18 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-25 22:41:27 UTC ---
Manuel, maybe because I'm very tired, but I'm not sure to understand why this
issue is still open: can you help reviewing it once more?


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/11393] Initializer of static const float class member is not legal in c++98
       [not found] <bug-11393-374@http.gcc.gnu.org/bugzilla/>
@ 2007-12-02 22:11 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 34+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-12-02 22:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #17 from pinskia at gcc dot gnu dot org  2007-12-02 22:11 -------
*** Bug 33750 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu dot
                   |                            |org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11393


^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2012-10-26 11:45 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-01 17:25 [Bug c++/11393] New: Initializer of static const float class member is not legal in c++98 rearnsha at gcc dot gnu dot org
2003-07-01 17:31 ` [Bug c++/11393] " pinskia at physics dot uc dot edu
2003-07-02 16:43 ` rearnsha at gcc dot gnu dot org
2003-07-02 16:47 ` pinskia at physics dot uc dot edu
2003-07-02 17:06 ` rearnsha at arm dot com
2003-07-02 23:28 ` jsm28 at cam dot ac dot uk
2003-07-04 11:10 ` [Bug c++/11393] New: " Gabriel Dos Reis
2003-07-04 11:10 ` [Bug c++/11393] " gdr at integrable-solutions dot net
2003-07-04 11:33 ` gdr at integrable-solutions dot net
2003-07-04 11:33 ` gdr at integrable-solutions dot net
2003-07-04 11:35 ` gdr at integrable-solutions dot net
2003-07-07 10:25 ` rearnsha at gcc dot gnu dot org
2003-07-07 10:25 ` rearnsha at gcc dot gnu dot org
2003-07-07 23:23 ` bangerth at dealii dot org
2003-08-11 15:32 ` lerdsuwa at gcc dot gnu dot org
2003-08-23  0:39 ` dhazeghi at yahoo dot com
2004-11-09 23:09 ` pinskia at gcc dot gnu dot org
2005-04-18 17:32 ` pinskia at gcc dot gnu dot org
2005-04-18 17:38 ` pinskia at gcc dot gnu dot org
2005-05-10 17:44 ` pinskia at gcc dot gnu dot org
     [not found] <bug-11393-374@http.gcc.gnu.org/bugzilla/>
2007-12-02 22:11 ` pinskia at gcc dot gnu dot org
     [not found] <bug-11393-4@http.gcc.gnu.org/bugzilla/>
2012-10-25 22:41 ` paolo.carlini at oracle dot com
2012-10-25 23:30 ` manu at gcc dot gnu.org
2012-10-25 23:44 ` manu at gcc dot gnu.org
2012-10-25 23:49 ` rnewman at compubrite dot com
2012-10-26  0:02 ` redi at gcc dot gnu.org
2012-10-26  0:16 ` manu at gcc dot gnu.org
2012-10-26  0:24 ` manu at gcc dot gnu.org
2012-10-26  1:12 ` redi at gcc dot gnu.org
2012-10-26  1:54 ` manu at gcc dot gnu.org
2012-10-26  2:05 ` manu at gcc dot gnu.org
2012-10-26  2:13 ` redi at gcc dot gnu.org
2012-10-26 11:44 ` paolo.carlini at oracle dot com
2012-10-26 11:45 ` manu at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).