When does gcc compile unused template code?
问题 I have the following (admittedly contrived) code that compiles just fine in gcc 6, but doesn't compile in gcc 7. Notice the use of an undeclared constructor in the definition of bar . This should print an error if the function is ever referenced elsewhere in the code (uncommenting foo.bar() causes gcc 6 to print an error). However, gcc 7 prints an error even if the function is not used. Some changes cause the code to also compile with gcc 7 (e.g. if B is replaced with T in the definition of A