public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53810] New: template class static not defined
@ 2012-06-29 20:31 ajrobb57 at gmail dot com
2012-06-29 20:41 ` [Bug c++/53810] " ajrobb57 at gmail dot com
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: ajrobb57 at gmail dot com @ 2012-06-29 20:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53810
Bug #: 53810
Summary: template class static not defined
Classification: Unclassified
Product: gcc
Version: 4.5.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: ajrobb57@gmail.com
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-cygwin/4.5.3/lto-wrapper.exe
Target: i686-pc-cygwin
Configured with:
/gnu/gcc/releases/respins/4.5.3-3/gcc4-4.5.3-3/src/gcc-4.5.3/configure
--srcdir=/gnu/gcc/releases/respins/4.5.3-3/gcc4-4.5.3-3/src/gcc-4.5.3
--prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin
--libexecdir=/usr/lib --datadir=/usr/share --localstatedir=/var
--sysconfdir=/etc --datarootdir=/usr/share --docdir=/usr/share/doc/gcc4 -C
--datadir=/usr/share --infodir=/usr/share/info --mandir=/usr/share/man -v
--with-gmp=/usr --with-mpfr=/usr --enable-bootstrap
--enable-version-specific-runtime-libs --libexecdir=/usr/lib --enable-static
--enable-shared --enable-shared-libgcc --disable-__cxa_atexit --with-gnu-ld
--with-gnu-as --with-dwarf2 --disable-sjlj-exceptions
--enable-languages=ada,c,c++,fortran,java,lto,objc,obj-c++ --enable-graphite
--enable-lto --enable-java-awt=gtk --disable-symvers --enable-libjava
--program-suffix=-4 --enable-libgomp --enable-libssp --enable-libada
--enable-threads=posix --with-arch=i686 --with-tune=generic
--enable-libgcj-sublibs CC=gcc-4 CXX=g++-4 CC_FOR_TARGET=gcc-4
CXX_FOR_TARGET=g++-4 GNATMAKE_FOR_TARGET=gnatmake GNATBIND_FOR_TARGET=gnatbind
--with-ecj-jar=/usr/share/java/ecj.jar
Thread model: posix
gcc version 4.5.3 (GCC)
class Class {
public:
static int const _n = n;
int simple() const {
return _n;
}
int const & complex() const {
return _n;
}
};
int main() {
Class<4> const & obj = Class<4>();
#if 1
// fail
return obj.complex();
#else
// OK
return obj.simple();
#endif
}
$ g++ -Wall -Wextra template.cpp -o template
/tmp/ccxosym6.o:template.cpp:(.text$_ZNK5ClassILi4EE7complexEv[Class<4>::complex()
const]+0x4): undefined reference to `Class<4>::_n'
collect2: ld returned 1 exit status
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/53810] template class static not defined
2012-06-29 20:31 [Bug c++/53810] New: template class static not defined ajrobb57 at gmail dot com
@ 2012-06-29 20:41 ` ajrobb57 at gmail dot com
2012-06-29 22:01 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ajrobb57 at gmail dot com @ 2012-06-29 20:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53810
--- Comment #1 from Andrew Robb <ajrobb57 at gmail dot com> 2012-06-29 20:41:08 UTC ---
template < int n >
class Class {
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/53810] template class static not defined
2012-06-29 20:31 [Bug c++/53810] New: template class static not defined ajrobb57 at gmail dot com
2012-06-29 20:41 ` [Bug c++/53810] " ajrobb57 at gmail dot com
@ 2012-06-29 22:01 ` pinskia at gcc dot gnu.org
2012-06-30 6:23 ` ajrobb57 at gmail dot com
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-06-29 22:01 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53810
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-06-29 22:01:07 UTC ---
GCC is having the correct behavior. You don't have a definition for the static
const class variable, only the declaration. You need the definition as you
implictly take the address of the variable (via a reference).
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/53810] template class static not defined
2012-06-29 20:31 [Bug c++/53810] New: template class static not defined ajrobb57 at gmail dot com
2012-06-29 20:41 ` [Bug c++/53810] " ajrobb57 at gmail dot com
2012-06-29 22:01 ` pinskia at gcc dot gnu.org
@ 2012-06-30 6:23 ` ajrobb57 at gmail dot com
2012-06-30 9:57 ` paolo.carlini at oracle dot com
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ajrobb57 at gmail dot com @ 2012-06-30 6:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53810
--- Comment #3 from Andrew Robb <ajrobb57 at gmail dot com> 2012-06-30 06:23:28 UTC ---
template< int n>
class Class {
public:
static int const _n = n;
I thought that _n was defined.
On 29/06/2012 23:01, pinskia at gcc dot gnu.org wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53810
>
> --- Comment #2 from Andrew Pinski<pinskia at gcc dot gnu.org> 2012-06-29 22:01:07 UTC ---
> GCC is having the correct behavior. You don't have a definition for the static
> const class variable, only the declaration. You need the definition as you
> implictly take the address of the variable (via a reference).
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/53810] template class static not defined
2012-06-29 20:31 [Bug c++/53810] New: template class static not defined ajrobb57 at gmail dot com
` (2 preceding siblings ...)
2012-06-30 6:23 ` ajrobb57 at gmail dot com
@ 2012-06-30 9:57 ` paolo.carlini at oracle dot com
2012-07-02 10:09 ` redi at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-06-30 9:57 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53810
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-06-30 09:57:28 UTC ---
Closing.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/53810] template class static not defined
2012-06-29 20:31 [Bug c++/53810] New: template class static not defined ajrobb57 at gmail dot com
` (3 preceding siblings ...)
2012-06-30 9:57 ` paolo.carlini at oracle dot com
@ 2012-07-02 10:09 ` redi at gcc dot gnu.org
2012-07-02 12:45 ` ajrobb57 at gmail dot com
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2012-07-02 10:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53810
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-07-02 10:09:26 UTC ---
See http://gcc.gnu.org/wiki/VerboseDiagnostics#missing_static_const_definition
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/53810] template class static not defined
2012-06-29 20:31 [Bug c++/53810] New: template class static not defined ajrobb57 at gmail dot com
` (4 preceding siblings ...)
2012-07-02 10:09 ` redi at gcc dot gnu.org
@ 2012-07-02 12:45 ` ajrobb57 at gmail dot com
2012-07-02 13:38 ` redi at gcc dot gnu.org
2012-07-02 13:41 ` ajrobb57 at gmail dot com
7 siblings, 0 replies; 9+ messages in thread
From: ajrobb57 at gmail dot com @ 2012-07-02 12:45 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53810
--- Comment #6 from Andrew Robb <ajrobb57 at gmail dot com> 2012-07-02 12:44:49 UTC ---
As this was a mistake in the language in the standard is should be a
warning.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/53810] template class static not defined
2012-06-29 20:31 [Bug c++/53810] New: template class static not defined ajrobb57 at gmail dot com
` (5 preceding siblings ...)
2012-07-02 12:45 ` ajrobb57 at gmail dot com
@ 2012-07-02 13:38 ` redi at gcc dot gnu.org
2012-07-02 13:41 ` ajrobb57 at gmail dot com
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2012-07-02 13:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53810
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-07-02 13:38:16 UTC ---
It's not a mistake in the standard, and it's not generally possible to warn at
compile-time about a missing definition at link-time.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/53810] template class static not defined
2012-06-29 20:31 [Bug c++/53810] New: template class static not defined ajrobb57 at gmail dot com
` (6 preceding siblings ...)
2012-07-02 13:38 ` redi at gcc dot gnu.org
@ 2012-07-02 13:41 ` ajrobb57 at gmail dot com
7 siblings, 0 replies; 9+ messages in thread
From: ajrobb57 at gmail dot com @ 2012-07-02 13:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53810
--- Comment #8 from Andrew Robb <ajrobb57 at gmail dot com> 2012-07-02 13:41:11 UTC ---
thank you
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-07-02 13:41 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-29 20:31 [Bug c++/53810] New: template class static not defined ajrobb57 at gmail dot com
2012-06-29 20:41 ` [Bug c++/53810] " ajrobb57 at gmail dot com
2012-06-29 22:01 ` pinskia at gcc dot gnu.org
2012-06-30 6:23 ` ajrobb57 at gmail dot com
2012-06-30 9:57 ` paolo.carlini at oracle dot com
2012-07-02 10:09 ` redi at gcc dot gnu.org
2012-07-02 12:45 ` ajrobb57 at gmail dot com
2012-07-02 13:38 ` redi at gcc dot gnu.org
2012-07-02 13:41 ` ajrobb57 at gmail dot com
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).