https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109172
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> --- No. This line means the test has to exit with an error referring to that line of the source, and it must contain the string "private": throw *new Demo; // { dg-error private } If it compiles without a matching error, the test fails. It doesn't matter whether it links successfully or not. In any case, the default action for compiler tests is to compile them, and not try to link, so it would never give a linker error even if the expected compilation error is absent. https://gcc.gnu.org/onlinedocs/gccint/Directives.html documents the default action, which is { dg-do compile }. If the test contained { dg-do link } or { dg-do run } then there would be a linker error if the private destructor wasn't diagnosed, but that still wouldn't match the expected error on line 12.