public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/30745]  New: Undefined static const
@ 2007-02-09 14:44 hans dot buchmann at fhso dot ch
  2007-02-09 14:52 ` [Bug c++/30745] " pinskia at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: hans dot buchmann at fhso dot ch @ 2007-02-09 14:44 UTC (permalink / raw)
  To: gcc-bugs

Compiling the code

class Class
{
 public:
   Class(const unsigned maxLine);

 private:
  static const unsigned MAX_LEN = 16;
  unsigned max;
  unsigned array[MAX_LEN];
};

Class::Class(const unsigned maxLine)
:max((maxLine<MAX_LEN)?maxLine
                      :MAX_LEN)
{
}

with the command:

g++ -Wall -O0  -fno-exceptions -c -o const-test.o const-test.cc

leaves Class::MAX_LEN undefined:

nm --demangle const-test.o
         U Class::MAX_LEN
00000028 T Class::Class(unsigned int)
00000000 T Class::Class(unsigned int)


The compiler  g++ -v

Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /var/tmp/portage/gcc-4.1.1/work/gcc-4.1.1/configure
 --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.1.1 
 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include 
 --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1 
 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1/man 
 --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1/info 
 --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4 
 --host=i686-pc-linux-gnu 
 --build=i686-pc-linux-gnu 
 --disable-altivec 
 --enable-nls 
 --without-included-gettext 
 --with-system-zlib 
 --disable-checking 
 --disable-werror 
 --disable-libunwind-exceptions 
 --disable-multilib 
 --disable-libmudflap 
 --disable-libssp 
 --disable-libgcj 
 --enable-languages=c,c++,fortran 
 --enable-shared --enable-threads=posix 
 --enable-__cxa_atexit 
 --enable-clocale=gnu
Thread model: posix
gcc version 4.1.1 (Gentoo 4.1.1)

Best regards

Hans Buchmann


-- 
           Summary: Undefined static const
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hans dot buchmann at fhso dot ch
 GCC build triplet:  i686-pc-linux-gnu
  GCC host triplet:  i686-pc-linux-gnu
GCC target triplet:  i686-pc-linux-gnu


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


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

* [Bug c++/30745] Undefined static const
  2007-02-09 14:44 [Bug c++/30745] New: Undefined static const hans dot buchmann at fhso dot ch
@ 2007-02-09 14:52 ` pinskia at gcc dot gnu dot org
  2007-02-10 12:17 ` hans dot buchmann at fhso dot ch
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-02-09 14:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2007-02-09 14:52 -------
This is not a bug, you still need a definition of the static const variable. 
You just have a declaration.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
  GCC build triplet| i686-pc-linux-gnu          |i686-pc-linux-gnu
   GCC host triplet| i686-pc-linux-gnu          |i686-pc-linux-gnu
 GCC target triplet| i686-pc-linux-gnu          |i686-pc-linux-gnu
         Resolution|                            |INVALID


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


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

* [Bug c++/30745] Undefined static const
  2007-02-09 14:44 [Bug c++/30745] New: Undefined static const hans dot buchmann at fhso dot ch
  2007-02-09 14:52 ` [Bug c++/30745] " pinskia at gcc dot gnu dot org
@ 2007-02-10 12:17 ` hans dot buchmann at fhso dot ch
  2007-02-10 21:12 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: hans dot buchmann at fhso dot ch @ 2007-02-10 12:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from hans dot buchmann at fhso dot ch  2007-02-10 12:17 -------

Inserting the line

 const unsigned Class::MAX_LEN=16;

results in the message

 const-test.cc:13: error: duplicate initialization of 'Class::MAX_LEN'

When I place the declaration outside the class the Symbol MAX_LEN is 
defined:

00000000 r MAX_LEN
00000028 T Class::Class(unsigned int)
00000000 T Class::Class(unsigned int)


-- 


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


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

* [Bug c++/30745] Undefined static const
  2007-02-09 14:44 [Bug c++/30745] New: Undefined static const hans dot buchmann at fhso dot ch
  2007-02-09 14:52 ` [Bug c++/30745] " pinskia at gcc dot gnu dot org
  2007-02-10 12:17 ` hans dot buchmann at fhso dot ch
@ 2007-02-10 21:12 ` pinskia at gcc dot gnu dot org
  2007-05-12  8:15 ` schwab at suse dot de
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-02-10 21:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2007-02-10 21:12 -------
The definition have to be not inialized if it was already initialized in the
declaration

The declaration is the one which is inside the class, the definition which is
the one which defines the memory space is the one out side of the class.

If you just declare/define the variable outside of the class, that is a
definition.


-- 


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


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

* [Bug c++/30745] Undefined static const
  2007-02-09 14:44 [Bug c++/30745] New: Undefined static const hans dot buchmann at fhso dot ch
                   ` (2 preceding siblings ...)
  2007-02-10 21:12 ` pinskia at gcc dot gnu dot org
@ 2007-05-12  8:15 ` schwab at suse dot de
  2007-08-23 16:34 ` pinskia at gcc dot gnu dot org
  2008-05-19  0:11 ` paolo dot carlini at oracle dot com
  5 siblings, 0 replies; 8+ messages in thread
From: schwab at suse dot de @ 2007-05-12  8:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from schwab at suse dot de  2007-05-12 09:15 -------
*** Bug 31904 has been marked as a duplicate of this bug. ***


-- 

schwab at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dennis0yang at gmail dot com


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


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

* [Bug c++/30745] Undefined static const
  2007-02-09 14:44 [Bug c++/30745] New: Undefined static const hans dot buchmann at fhso dot ch
                   ` (3 preceding siblings ...)
  2007-05-12  8:15 ` schwab at suse dot de
@ 2007-08-23 16:34 ` pinskia at gcc dot gnu dot org
  2008-05-19  0:11 ` paolo dot carlini at oracle dot com
  5 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-08-23 16:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2007-08-23 16:34 -------
*** Bug 33161 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sylvain dot pion at sophia
                   |                            |dot inria dot fr


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


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

* [Bug c++/30745] Undefined static const
  2007-02-09 14:44 [Bug c++/30745] New: Undefined static const hans dot buchmann at fhso dot ch
                   ` (4 preceding siblings ...)
  2007-08-23 16:34 ` pinskia at gcc dot gnu dot org
@ 2008-05-19  0:11 ` paolo dot carlini at oracle dot com
  5 siblings, 0 replies; 8+ messages in thread
From: paolo dot carlini at oracle dot com @ 2008-05-19  0:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from paolo dot carlini at oracle dot com  2008-05-19 00:10 -------
*** Bug 36261 has been marked as a duplicate of this bug. ***


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Bernd dot Donner at gmx dot
                   |                            |net


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


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

* [Bug c++/30745] Undefined static const
       [not found] <bug-30745-4@http.gcc.gnu.org/bugzilla/>
@ 2010-10-17 11:37 ` schwab@linux-m68k.org
  0 siblings, 0 replies; 8+ messages in thread
From: schwab@linux-m68k.org @ 2010-10-17 11:37 UTC (permalink / raw)
  To: gcc-bugs

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

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rarrum at gmail dot com

--- Comment #7 from Andreas Schwab <schwab@linux-m68k.org> 2010-10-17 11:36:54 UTC ---
*** Bug 46054 has been marked as a duplicate of this bug. ***


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

end of thread, other threads:[~2010-10-17 11:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-09 14:44 [Bug c++/30745] New: Undefined static const hans dot buchmann at fhso dot ch
2007-02-09 14:52 ` [Bug c++/30745] " pinskia at gcc dot gnu dot org
2007-02-10 12:17 ` hans dot buchmann at fhso dot ch
2007-02-10 21:12 ` pinskia at gcc dot gnu dot org
2007-05-12  8:15 ` schwab at suse dot de
2007-08-23 16:34 ` pinskia at gcc dot gnu dot org
2008-05-19  0:11 ` paolo dot carlini at oracle dot com
     [not found] <bug-30745-4@http.gcc.gnu.org/bugzilla/>
2010-10-17 11:37 ` schwab@linux-m68k.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).