public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/20547] New: undefined reference to "static const" fields of classes
@ 2005-03-19  6:59 Hu dot YuehWei at gmail dot com
  2005-03-19 13:45 ` [Bug c++/20547] " pinskia at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 12+ messages in thread
From: Hu dot YuehWei at gmail dot com @ 2005-03-19  6:59 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1324 bytes --]

The sample codes¡G
==========================================
#include <iostream>
#include <vector>

struct T
{
  static char const a = 3;
};

std::vector<char> ddd;

int
main()
{
  ddd.push_back(T::a); /* this line of codes trigger the errors */

  std::cerr << ddd.front() << std::endl;

  return 0;
}
========================================

gcc-3.0.x 3.2.x 3.3.x 3.4.x compile the above program will produce errors like this:
=======================================
/tmp/ccPOPHZ6.o(.text+0x124): In function `main':
: undefined reference to `T::a'
collect2: ld returned 1 exit status
=======================================

However, if I use gcc-2.95, then there will be no errors.

If I modify the codes from:

...
ddd.push_back(T::a);
...

to

...
ddd.push_back(static_cast<char>(T::a));
...

then gcc-3.0.x 3.2.x 3.3.x 3.4.x will be fine.

Is this a bug in gcc 3.x?

-- 
           Summary: undefined reference to "static const" fields of classes
           Product: gcc
           Version: 3.4.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Hu dot YuehWei at gmail dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 12+ messages in thread
[parent not found: <bug-20547-10303@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2006-09-25 21:11 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-19  6:59 [Bug c++/20547] New: undefined reference to "static const" fields of classes Hu dot YuehWei at gmail dot com
2005-03-19 13:45 ` [Bug c++/20547] " pinskia at gcc dot gnu dot org
2005-03-19 13:53 ` Hu dot YuehWei at gmail dot com
2005-03-19 14:01 ` Hu dot YuehWei at gmail dot com
2005-03-19 14:03 ` pinskia at gcc dot gnu dot org
2005-03-19 14:16 ` Hu dot YuehWei at gmail dot com
2005-03-19 14:34 ` pinskia at gcc dot gnu dot org
2005-03-19 18:26 ` Hu dot YuehWei at gmail dot com
2005-03-19 18:36 ` pinskia at gcc dot gnu dot org
2005-03-20  7:59 ` Hu dot YuehWei at gmail dot com
2005-03-20 13:55 ` lerdsuwa at gcc dot gnu dot org
     [not found] <bug-20547-10303@http.gcc.gnu.org/bugzilla/>
2006-09-25 21:11 ` 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).