This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/20547] undefined reference to "static const" fields of classes
- From: "Hu dot YuehWei at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Mar 2005 14:15:59 -0000
- Subject: [Bug c++/20547] undefined reference to "static const" fields of classes
- References: <20050319065920.20547.Hu.YuehWei@gmail.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From Hu dot YuehWei at gmail dot com 2005-03-19 14:15 -------
I understand what you mean.
But why the following codes works:
#include <iostream>
#include <vector>
struct T
{
static char const a = 3;
};
std::vector<char> ddd;
int
main()
{
ddd.push_back(static_cast<char>(T::a)); // <========= here
std::cerr << ddd.front() << std::endl;
return 0;
}
and if I pass an constant to a function which takes its address,
then why the folloing codes doesn't produce errors?
void
fff(char const &a)
{
}
int
main()
{
fff(4);
return 0;
}
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20547