[Bug c++/84573] missing warning on an uninstantiated function template returning T with no return statement
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84573 Martin Sebor changed: What|Removed |Added Status|WAITING |NEW --- Comment #4 from Martin Sebor --- I believe the warning would be helpful because as I mentioned in comment #0: ...the only valid specialization of such a template is one where T = void it's likely that the missing return statement is a mistake... A function template that returns a template argument should be defined that way even if it's meant to be instantiated on void: template T g () { return T (); } // valid for any default-constructible type, even void void h () { return g(); } // valid Warning for a missing return statement would be helpful in template libraries that rarely instantiate all their code either during a build or in their tests.
[Bug c++/84573] missing warning on an uninstantiated function template returning T with no return statement
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84573 Marek Polacek changed: What|Removed |Added CC||mpolacek at gcc dot gnu.org --- Comment #3 from Marek Polacek --- I personally think we should not add such a warning.
[Bug c++/84573] missing warning on an uninstantiated function template returning T with no return statement
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84573 Andrew Pinski changed: What|Removed |Added Status|UNCONFIRMED |WAITING Ever confirmed|0 |1 Last reconfirmed||2021-12-17 --- Comment #2 from Andrew Pinski --- Plus this is valid: template T g () { } // missing warning template<> void g(); So having a return here would be invalid code and the warning might influence someone to add it. What do you think?
[Bug c++/84573] missing warning on an uninstantiated function template returning T with no return statement
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84573 Andrew Pinski changed: What|Removed |Added Severity|normal |enhancement --- Comment #1 from Andrew Pinski --- No compiler (ICC, GCC, MSVC or clang) warns about this and I don't know how useful it is really.