Created
April 15, 2020 11:59
-
-
Save ryb-ableton/1805b61e2d0976de4ba04c2aa2f5992b to your computer and use it in GitHub Desktop.
libc++ type_index uniqueness bug
This file contains 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
#!/bin/bash | |
clang++ -std=c++11 -stdlib=libc++ tu1.cpp tu2.cpp main.cpp -o test | |
./test | |
if [ $? -eq 0 ] | |
then | |
echo "Success" | |
exit 0 | |
else | |
echo "Failure" | |
exit 1 | |
fi |
This file contains 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
#include <vector> | |
#include <typeindex> | |
extern std::vector<std::type_index> registry; | |
void register1(); | |
void register2(); |
This file contains 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
#include "common.hpp" | |
#include <cassert> | |
std::vector<std::type_index> registry; | |
int main() | |
{ | |
register1(); | |
register2(); | |
assert(registry.size() == 2); | |
assert(registry[0] != registry[1]); | |
} |
This file contains 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
#include "common.hpp" | |
namespace | |
{ | |
struct A | |
{ | |
bool x; | |
}; | |
} | |
void register1() | |
{ | |
registry.emplace_back(std::type_index{typeid(A)}); | |
} |
This file contains 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
#include "common.hpp" | |
namespace | |
{ | |
struct A | |
{ | |
int x, y; | |
}; | |
} | |
void register2() | |
{ | |
registry.emplace_back(std::type_index{typeid(A)}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment