This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/42330] undefined reference to "static const int" in class when passing as "const int &" to a function
- From: "redi at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Dec 2009 09:50:45 -0000
- Subject: [Bug c++/42330] undefined reference to "static const int" in class when passing as "const int &" to a function
- References: <bug-42330-18537@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from redi at gcc dot gnu dot org 2009-12-08 09:50 -------
(In reply to comment #3)
> (In reply to comment #2)
> > and i don't want to write lots of "const int A<N>::i"...
>
> You have to, your code is not valid if you use A::i in the program but it has
> no definition. This is not a compiler bug.
Actually you don't have to write lots, just one:
template<int N> const A<N>::i;
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42330