Skip to content

Instantly share code, notes, and snippets.

@detunized
Created December 17, 2013 16:32
Show Gist options
  • Save detunized/8007873 to your computer and use it in GitHub Desktop.
Save detunized/8007873 to your computer and use it in GitHub Desktop.
Strange compile error Clang vs GCC
$ clang -c test.cpp; gcc -c test.cpp
test.cpp:10:7: error: read-only variable is not assignable
x = 0;
~ ^
test.cpp:26:7: note: in instantiation of member function 'A<float>::f' requested here
a.f(0);
^
1 error generated.
template <typename T>
struct A
{
void f(const int);
};
template <typename T>
void A<T>::f(int x)
{
x = 0;
}
struct B
{
void f(const int);
};
void B::f(int x)
{
x = 0;
}
void f()
{
A<float> a;
a.f(0);
B b;
b.f(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment