https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84573
Bug ID: 84573 Summary: missing warning on an uninstantiated function template returning T with no return statement Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- G++ diagnoses a return statement with a value in a function template returning void even when the template is never instantiated, but it doesn't issue a warning when a function template declared to return the template argument T. Since the only valid specialization of such a template is one where T = void it's likely that the missing return statement is a mistake that issuing a warning for would be helpful. $ cat z.C && gcc -Wall -Wextra -S z.C template <class T> void f () { return 1; } // error: return-statement with a value template <class T> T g () { } // missing warning z.C: In function ‘void f()’: z.C:2:20: error: return-statement with a value, in function returning ‘void’ [-fpermissive] void f () { return 1; } // error: return-statement with a value ^