https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83814
--- Comment #9 from David Binderman <dcb314 at hotmail dot com> --- This similar code: extern "C" void *memset(void *, int, unsigned long) ; char *a ; template < class b > void c() { memset(a + sizeof(b), 0, 0); } does this: bug411-b.cc: In function ‘void c()’: bug411-b.cc:6:28: internal compiler error: in build2, at tree.c:4682 memset(a + sizeof(b), 0, 0); ^ 0x1359c45 build2(tree_code, tree_node*, tree_node*, tree_node*) ../../trunk/gcc/tree.c:4681 0xb8cc4f build2_loc ../../trunk/gcc/tree.h:4112 0xb8cc4f fold_build2_loc(unsigned int, tree_code, tree_node*, tree_node*, tree_n ode*) ../../trunk/gcc/fold-const.c:12330 0xb8321d fold_binary_loc(unsigned int, tree_code, tree_node*, tree_node*, tree_n ode*) I am not sure if your candidate patch fixes this code too.