public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/84573] missing warning on an uninstantiated function template returning T with no return statement
       [not found] <bug-84573-4@http.gcc.gnu.org/bugzilla/>
@ 2021-12-17  3:43 ` pinskia at gcc dot gnu.org
  2021-12-17  3:45 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-17  3:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84573

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
No compiler (ICC, GCC, MSVC or clang) warns about this and I don't know how
useful it is really.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/84573] missing warning on an uninstantiated function template returning T with no return statement
       [not found] <bug-84573-4@http.gcc.gnu.org/bugzilla/>
  2021-12-17  3:43 ` [Bug c++/84573] missing warning on an uninstantiated function template returning T with no return statement pinskia at gcc dot gnu.org
@ 2021-12-17  3:45 ` pinskia at gcc dot gnu.org
  2021-12-17 14:17 ` mpolacek at gcc dot gnu.org
  2021-12-17 15:43 ` msebor at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-17  3:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84573

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-12-17

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Plus this is valid:
template <class T>
T g () { }   // missing warning

template<> void g<void>();


So having a return here would be invalid code and the warning might influence
someone to add it.

What do you think?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/84573] missing warning on an uninstantiated function template returning T with no return statement
       [not found] <bug-84573-4@http.gcc.gnu.org/bugzilla/>
  2021-12-17  3:43 ` [Bug c++/84573] missing warning on an uninstantiated function template returning T with no return statement pinskia at gcc dot gnu.org
  2021-12-17  3:45 ` pinskia at gcc dot gnu.org
@ 2021-12-17 14:17 ` mpolacek at gcc dot gnu.org
  2021-12-17 15:43 ` msebor at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-12-17 14:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84573

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I personally think we should not add such a warning.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/84573] missing warning on an uninstantiated function template returning T with no return statement
       [not found] <bug-84573-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2021-12-17 14:17 ` mpolacek at gcc dot gnu.org
@ 2021-12-17 15:43 ` msebor at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-12-17 15:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84573

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW

--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
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 <class T>
  T g () { return T (); }   // valid for any default-constructible type, even
void

  void h () { return g<void>(); }   // 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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-12-17 15:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-84573-4@http.gcc.gnu.org/bugzilla/>
2021-12-17  3:43 ` [Bug c++/84573] missing warning on an uninstantiated function template returning T with no return statement pinskia at gcc dot gnu.org
2021-12-17  3:45 ` pinskia at gcc dot gnu.org
2021-12-17 14:17 ` mpolacek at gcc dot gnu.org
2021-12-17 15:43 ` msebor at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).