Last active
February 9, 2020 17:56
-
-
Save kevinushey/cfa848be2d39ddd110f893d9b6c5ac9c to your computer and use it in GitHub Desktop.
Fails to compile with gcc 10 on Fedora Rawhide.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void* callback(const char* name); | |
extern "C" { | |
inline void f1() | |
{ | |
static void (*f)(); | |
f = (void(*)()) callback("f1"); | |
f(); | |
} | |
inline void f2() | |
{ | |
static void (*f)(); | |
f = (void(*)()) callback("f2"); | |
f(); | |
} | |
} // extern "C" | |
int main() | |
{ | |
f1(); | |
f2(); | |
} |
I've removed the implementation of callback()
so at least this should no longer be UB. The underlying issue though is as @Enchufa2 says, with duplicate (and non-mangled) names for f
generated.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That causes a runtime crash, but that's not the point. The point here is that gcc 10 generates two symbols
f
for lines 10 and 17, and they collide. Previous versions of gcc generate_ZZ2f1E1f
and_ZZ2f2E1f
respectively, i.e.,f1::f
andf2::f
demangled.