Last active
August 29, 2015 14:05
-
-
Save o11c/208348992823821354d1 to your computer and use it in GitHub Desktop.
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
test-* | |
var-* |
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
all: test-clang++-3.4 | |
all: test-clang++-3.5 | |
all: test-clang++-3.6 | |
all: test-g++-4.4 | |
all: test-g++-4.6 | |
all: test-g++-4.7 | |
all: test-g++-4.8 | |
all: test-g++-4.9 | |
override FLAGS += -std=c++0x -g -O0 | |
var-%: var.cpp | |
$* ${FLAGS} -o $@ $< | |
test-%: var-% script.gdb | |
gdb -batch -x script.gdb $< | |
touch $@ | |
.DELETE_ON_ERROR: | |
.SECONDARY: | |
clean: | |
rm -f test-* var-* |
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
# vim: ft=python | |
start | |
python | |
import sys | |
import traceback | |
error = 0 | |
try: | |
for template in ['Foo', 'Bar', 'Baz']: | |
try: | |
var = gdb.parse_and_eval('(%s<int, const char *> *)0' % template).type.target() | |
except Exception as e: | |
error = 1 | |
var = e | |
traceback.print_exc() | |
print '%s:' % template, var | |
try: | |
tp0 = var.template_argument(0) | |
except Exception as e: | |
error = 1 | |
tp0 = e | |
traceback.print_exc() | |
print '%s.0:' % template, tp0 | |
try: | |
tp1 = var.template_argument(1) | |
except Exception as e: | |
error = 1 | |
tp1 = e | |
traceback.print_exc() | |
print '%s.1:' % template, tp1 | |
except: | |
error = 1 | |
traceback.print_exc() | |
sys.exit(error) | |
end |
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 <cstdio> | |
// Foo seems to work fine | |
template<class... T> | |
struct Foo {}; | |
// Bar is often buggy | |
template<class F, class... R> | |
struct Bar {}; | |
// Baz is a workaround | |
template<class... T> | |
struct Baz; | |
template<class F, class... R> | |
struct Baz<F, R...> {}; | |
template<class T> | |
void frob(const T& v, bool c) | |
{ | |
// prevent compiler from optimizing out | |
if (c) | |
printf("%p\n", &v); | |
} | |
int main(int argc, char **argv) | |
{ | |
frob(Foo<int, const char *>(), argc == 0); | |
frob(Bar<int, const char *>(), argc == 0); | |
frob(Baz<int, const char *>(), argc == 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment