public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57857] New: argument of decltype used by no return value warning
@ 2013-07-09  2:42 potswa at mac dot com
  2013-07-09  2:46 ` [Bug c++/57857] " potswa at mac dot com
  2021-08-04 19:27 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: potswa at mac dot com @ 2013-07-09  2:42 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57857

            Bug ID: 57857
           Summary: argument of decltype used by no return value warning
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: potswa at mac dot com

The following program complains that "declval() must not be used!" in a static
assertion if -Wall is passed. But declval() is only present in the unevaluated
context of a decltype specifier.

The issue seems to be linked to the generation of the warning message. But the
warning message will be present without the static_assert if the function has
more than one exit point, such as if(0) throw; or if(0) return; (the latter
using -fpermissive).


#include <utility>

template <typename U>
auto foo() -> decltype(std::declval<U>() + std::declval<U>());

template <typename T>
decltype(foo<T>()) bar(T) {
//  if ( 0 ) throw;
}

int main()
{ bar(1); }


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

* [Bug c++/57857] argument of decltype used by no return value warning
  2013-07-09  2:42 [Bug c++/57857] New: argument of decltype used by no return value warning potswa at mac dot com
@ 2013-07-09  2:46 ` potswa at mac dot com
  2021-08-04 19:27 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: potswa at mac dot com @ 2013-07-09  2:46 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57857

--- Comment #1 from David Krauss <potswa at mac dot com> ---
Narrowing down the cause, the statement { 0; } silences the error but {
void(0); } does not.


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

* [Bug c++/57857] argument of decltype used by no return value warning
  2013-07-09  2:42 [Bug c++/57857] New: argument of decltype used by no return value warning potswa at mac dot com
  2013-07-09  2:46 ` [Bug c++/57857] " potswa at mac dot com
@ 2021-08-04 19:27 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-04 19:27 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |5.5.0
           Keywords|                            |rejects-valid
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=71187
      Known to work|                            |6.1.0
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
GCC 6+ produces:
<source>: In instantiation of 'decltype (foo<T>()) bar(T) [with T = int;
decltype (foo<T>()) = int]':
<source>:13:8:   required from here
<source>:10:1: warning: no return statement in function returning non-void
[-Wreturn-type]
 }
 ^

And no calling of the static_assert .

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

end of thread, other threads:[~2021-08-04 19:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-09  2:42 [Bug c++/57857] New: argument of decltype used by no return value warning potswa at mac dot com
2013-07-09  2:46 ` [Bug c++/57857] " potswa at mac dot com
2021-08-04 19:27 ` pinskia 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).