public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/23370] No error at -O1 for static const class member passed by reference
       [not found] <bug-23370-8581@http.gcc.gnu.org/bugzilla/>
@ 2006-03-07 19:47 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-07 19:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2006-03-07 19:47 -------
*** Bug 26597 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |teufl at weyl dot math dot
                   |                            |tugraz dot at


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


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

* [Bug c++/23370] No error at -O1 for static const class member passed by reference
  2005-08-13  4:12 [Bug c++/23370] New: " flash at pobox dot com
  2005-08-13  4:13 ` [Bug c++/23370] " flash at pobox dot com
  2005-08-13  4:19 ` flash at pobox dot com
@ 2005-08-13  6:42 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-13  6:42 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-08-13 06:42 -------
Since the static const can be "inlined" at higher level of optimizations which is allowed by the C++ 
standard, this is not a bug.

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


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


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

* [Bug c++/23370] No error at -O1 for static const class member passed by reference
  2005-08-13  4:12 [Bug c++/23370] New: " flash at pobox dot com
  2005-08-13  4:13 ` [Bug c++/23370] " flash at pobox dot com
@ 2005-08-13  4:19 ` flash at pobox dot com
  2005-08-13  6:42 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: flash at pobox dot com @ 2005-08-13  4:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From flash at pobox dot com  2005-08-13 04:18 -------
Here's the discussion in our developer forum about the validity of this code; the rejection was originally 
reported as a bug against our compiler.

At 4:34 PM -0500 2/16/04, Stuart A. Malone wrote:
>But when I compile this kind of code using the native compiler, the 
>linker complains that Foo::kVersionNumber is an undefined symbol. 
>If I try to mollify it by placing code in my .cpp file like this:
>
> const int16_t Foo::kVersionNumber = 3;
>
>The compiler complains that the symbol has been defined twice.
>
>So how do I win?

I checked a reference manual[1] last night, which said that the 
definition should be:

const int16_t Foo::kVersionNumber;

Keep the "= 3" in the class definition, like you did before.  All 
you're doing with the above line is telling the compiler and linker 
where the storage should be defined.

-- Keith Rollin
-- Development Tools engineer

[1] "The C Programming Language", Special Edition, p. 249, section 
10.4.6.2, "Member Constants", where it says "If (and only if) you use 
an initialized member in a way that requires it to be stored as an 
object in memory, the member must be (uniquely) defined somewhere. 
The initializer may not be repeated: <example>".


-- 


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


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

* [Bug c++/23370] No error at -O1 for static const class member passed by reference
  2005-08-13  4:12 [Bug c++/23370] New: " flash at pobox dot com
@ 2005-08-13  4:13 ` flash at pobox dot com
  2005-08-13  4:19 ` flash at pobox dot com
  2005-08-13  6:42 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: flash at pobox dot com @ 2005-08-13  4:13 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From flash at pobox dot com  2005-08-13 04:13 -------
Created an attachment (id=9489)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=9489&action=view)
Llamagrahpics_static_constant_by_ref.cpp


-- 


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


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

end of thread, other threads:[~2006-03-07 19:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-23370-8581@http.gcc.gnu.org/bugzilla/>
2006-03-07 19:47 ` [Bug c++/23370] No error at -O1 for static const class member passed by reference pinskia at gcc dot gnu dot org
2005-08-13  4:12 [Bug c++/23370] New: " flash at pobox dot com
2005-08-13  4:13 ` [Bug c++/23370] " flash at pobox dot com
2005-08-13  4:19 ` flash at pobox dot com
2005-08-13  6:42 ` pinskia at gcc dot gnu dot 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).