Groups
Groups
Sign in
Groups
Groups
gnu.g++.help
Conversations
About
Send feedback
Help
Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss
Learn more
Code doesn't compile with GCC, but does with Clang and ICC
9 views
Skip to first unread message
Nikos Chantziaras
unread,
Dec 7, 2012, 8:14:00 PM
12/7/12
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to help-gp...@gnu.org
Why doesn't the below code compile with GCC?
#include <iostream>
template <typename T>
static void fFunc()
{
static T var;
(void)var; // Suppress set-but-not-used warning.
struct g {
static void gFunc()
{
std::cin >> var;
};
};
g::gFunc();
}
int main()
{
fFunc<int>();
}
It fails at link time with:
/tmp/ccYDfCzj.o: In function `gFunc':
tst.cpp:11: undefined reference to `var'
I'm using GCC 4.7.2 on Gentoo Linux (x86-64). It compiles fine with
Clang (3.1) and ICC (13.0.0).
0 new messages