public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94742] New: Incorrect "no return statement" warning with [[noreturn]] and __FUNCTION__
@ 2020-04-24 10:12 didier.gcc at trosset dot fr
  2020-04-24 11:06 ` [Bug c++/94742] [8/9/10 Regression] " jakub at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: didier.gcc at trosset dot fr @ 2020-04-24 10:12 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94742
           Summary: Incorrect "no return statement" warning with
                    [[noreturn]] and __FUNCTION__
           Product: gcc
           Version: 8.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: didier.gcc at trosset dot fr
  Target Milestone: ---

g++ version 8.3.0, default compiler for Debian 10, issues an incorrect "no
return statement in function returning non-void" when the __FUNCTION__ macro is
used to call a [[noreturn]] function.

This looks similar to bug 30988. This later is fixed, but the following code
still issue this incorrect warning. Similar to 30988, if __FUNCTION__ is casted
to char const*, the warning vanishes.

===================
template <class T> [[noreturn]] void Throw( T const& t, char const*  /* f */ )
{ throw T(t); }

template <class U>
int DoIt()
{
    //::Throw( int(42), __FILE__ );    // No warning
    ::Throw( int(42), __FUNCTION__ );  // warning: no return statement
}

int main()
{
    DoIt<long>();
    return 0;
}

===================

$ g++ -Wall -Wextra -v gcc-test-function.cpp
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 8.3.0-6'
--with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.3.0 (Debian 8.3.0-6)
COLLECT_GCC_OPTIONS='-Wall' '-Wextra' '-v' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/8/cc1plus -quiet -v -imultiarch x86_64-linux-gnu
-D_GNU_SOURCE gcc-test-function.cpp -quiet -dumpbase gcc-test-function.cpp
-mtune=generic -march=x86-64 -auxbase gcc-test-function -Wall -Wextra -version
-o /tmp/ccMsF2uX.s
GNU C++14 (Debian 8.3.0-6) version 8.3.0 (x86_64-linux-gnu)
        compiled by GNU C version 8.3.0, GMP version 6.1.2, MPFR version 4.0.2,
MPC version 1.1.0, isl version isl-0.20-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/8"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/8/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/8
 /usr/include/x86_64-linux-gnu/c++/8
 /usr/include/c++/8/backward
 /usr/lib/gcc/x86_64-linux-gnu/8/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/8/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C++14 (Debian 8.3.0-6) version 8.3.0 (x86_64-linux-gnu)
        compiled by GNU C version 8.3.0, GMP version 6.1.2, MPFR version 4.0.2,
MPC version 1.1.0, isl version isl-0.20-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 3c854693d01dc9a844a56a0b1ab1c0f4
gcc-test-function.cpp: In function ‘int DoIt()’:
gcc-test-function.cpp:9:1: warning: no return statement in function returning
non-void [-Wreturn-type]
 }
 ^
COLLECT_GCC_OPTIONS='-Wall' '-Wextra' '-v' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
 as -v --64 -o /tmp/cc02zIqQ.o /tmp/ccMsF2uX.s
GNU assembler version 2.31.1 (x86_64-linux-gnu) using BFD version (GNU Binutils
for Debian) 2.31.1
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/8/:/usr/lib/gcc/x86_64-linux-gnu/8/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/8/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/8/:/usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/8/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/8/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-Wall' '-Wextra' '-v' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/8/collect2 -plugin
/usr/lib/gcc/x86_64-linux-gnu/8/liblto_plugin.so
-plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
-plugin-opt=-fresolution=/tmp/ccHHQHoJ.res -plugin-opt=-pass-through=-lgcc_s
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id
--eh-frame-hdr -m elf_x86_64 --hash-style=gnu -dynamic-linker
/lib64/ld-linux-x86-64.so.2 -pie
/usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o
/usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/crti.o
/usr/lib/gcc/x86_64-linux-gnu/8/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/8
-L/usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu
-L/usr/lib/gcc/x86_64-linux-gnu/8/../../../../lib -L/lib/x86_64-linux-gnu
-L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib
-L/usr/lib/gcc/x86_64-linux-gnu/8/../../.. /tmp/cc02zIqQ.o -lstdc++ -lm -lgcc_s
-lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/8/crtendS.o
/usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/crtn.o
COLLECT_GCC_OPTIONS='-Wall' '-Wextra' '-v' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'

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

* [Bug c++/94742] [8/9/10 Regression] Incorrect "no return statement" warning with [[noreturn]] and __FUNCTION__
  2020-04-24 10:12 [Bug c++/94742] New: Incorrect "no return statement" warning with [[noreturn]] and __FUNCTION__ didier.gcc at trosset dot fr
@ 2020-04-24 11:06 ` jakub at gcc dot gnu.org
  2020-04-24 12:38 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-04-24 11:06 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Incorrect "no return        |[8/9/10 Regression]
                   |statement" warning with     |Incorrect "no return
                   |[[noreturn]] and            |statement" warning with
                   |__FUNCTION__                |[[noreturn]] and
                   |                            |__FUNCTION__
   Target Milestone|---                         |8.5
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r8-4349-g1b6fa695ab5e6f6fd57ed9264b336f06f440125b when
-Wreturn-type has been enabled by default, but with explicit -Wreturn-type and
__attribute__((noreturn)) instead of [[noreturn]] already failed in r105000.

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

* [Bug c++/94742] [8/9/10 Regression] Incorrect "no return statement" warning with [[noreturn]] and __FUNCTION__
  2020-04-24 10:12 [Bug c++/94742] New: Incorrect "no return statement" warning with [[noreturn]] and __FUNCTION__ didier.gcc at trosset dot fr
  2020-04-24 11:06 ` [Bug c++/94742] [8/9/10 Regression] " jakub at gcc dot gnu.org
@ 2020-04-24 12:38 ` jakub at gcc dot gnu.org
  2020-04-24 22:12 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-04-24 12:38 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-04-24
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 48368
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48368&action=edit
gcc10-pr94742.patch

Untested fix.

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

* [Bug c++/94742] [8/9/10 Regression] Incorrect "no return statement" warning with [[noreturn]] and __FUNCTION__
  2020-04-24 10:12 [Bug c++/94742] New: Incorrect "no return statement" warning with [[noreturn]] and __FUNCTION__ didier.gcc at trosset dot fr
  2020-04-24 11:06 ` [Bug c++/94742] [8/9/10 Regression] " jakub at gcc dot gnu.org
  2020-04-24 12:38 ` jakub at gcc dot gnu.org
@ 2020-04-24 22:12 ` cvs-commit at gcc dot gnu.org
  2020-04-24 22:24 ` [Bug c++/94742] [8/9 " jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-04-24 22:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:4ff685a8705e8ee55fa86e75afb769ffb0975aea

commit r10-7953-g4ff685a8705e8ee55fa86e75afb769ffb0975aea
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat Apr 25 00:11:35 2020 +0200

    c++: Avoid -Wreturn-type warning if a template fn calls noreturn template
fn [PR94742]

    finish_call_expr already has code to set
current_function_returns_abnormally
    if a template calls a noreturn function, but on the following testcase it
    doesn't call a FUNCTION_DECL, but TEMPLATE_DECL instead, in which case
    we didn't check noreturn at all and just assumed it could return.

    2020-04-25  Jakub Jelinek  <jakub@redhat.com>

            PR c++/94742
            * semantics.c (finish_call_expr): When looking if all overloads
            are noreturn, use STRIP_TEMPLATE to look through TEMPLATE_DECLs.

            * g++.dg/warn/Wreturn-type-12.C: New test.

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

* [Bug c++/94742] [8/9 Regression] Incorrect "no return statement" warning with [[noreturn]] and __FUNCTION__
  2020-04-24 10:12 [Bug c++/94742] New: Incorrect "no return statement" warning with [[noreturn]] and __FUNCTION__ didier.gcc at trosset dot fr
                   ` (2 preceding siblings ...)
  2020-04-24 22:12 ` cvs-commit at gcc dot gnu.org
@ 2020-04-24 22:24 ` jakub at gcc dot gnu.org
  2020-09-16 19:20 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-04-24 22:24 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[8/9/10 Regression]         |[8/9 Regression] Incorrect
                   |Incorrect "no return        |"no return statement"
                   |statement" warning with     |warning with [[noreturn]]
                   |[[noreturn]] and            |and __FUNCTION__
                   |__FUNCTION__                |

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed on the trunk so far.

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

* [Bug c++/94742] [8/9 Regression] Incorrect "no return statement" warning with [[noreturn]] and __FUNCTION__
  2020-04-24 10:12 [Bug c++/94742] New: Incorrect "no return statement" warning with [[noreturn]] and __FUNCTION__ didier.gcc at trosset dot fr
                   ` (3 preceding siblings ...)
  2020-04-24 22:24 ` [Bug c++/94742] [8/9 " jakub at gcc dot gnu.org
@ 2020-09-16 19:20 ` cvs-commit at gcc dot gnu.org
  2020-09-17 17:37 ` jakub at gcc dot gnu.org
  2021-12-17  5:24 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-16 19:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:e9dbd80b5e62a126ccb40970f0fb233f7e0ac3a6

commit r9-8885-ge9dbd80b5e62a126ccb40970f0fb233f7e0ac3a6
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat Apr 25 00:11:35 2020 +0200

    c++: Avoid -Wreturn-type warning if a template fn calls noreturn template
fn [PR94742]

    finish_call_expr already has code to set
current_function_returns_abnormally
    if a template calls a noreturn function, but on the following testcase it
    doesn't call a FUNCTION_DECL, but TEMPLATE_DECL instead, in which case
    we didn't check noreturn at all and just assumed it could return.

    2020-04-25  Jakub Jelinek  <jakub@redhat.com>

            PR c++/94742
            * semantics.c (finish_call_expr): When looking if all overloads
            are noreturn, use STRIP_TEMPLATE to look through TEMPLATE_DECLs.

            * g++.dg/warn/Wreturn-type-12.C: New test.

    (cherry picked from commit 4ff685a8705e8ee55fa86e75afb769ffb0975aea)

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

* [Bug c++/94742] [8/9 Regression] Incorrect "no return statement" warning with [[noreturn]] and __FUNCTION__
  2020-04-24 10:12 [Bug c++/94742] New: Incorrect "no return statement" warning with [[noreturn]] and __FUNCTION__ didier.gcc at trosset dot fr
                   ` (4 preceding siblings ...)
  2020-09-16 19:20 ` cvs-commit at gcc dot gnu.org
@ 2020-09-17 17:37 ` jakub at gcc dot gnu.org
  2021-12-17  5:24 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-09-17 17:37 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 8.5 in r8-10492-g012e366a3928303aa1082876313e0bc3ea67190e and by the
above commit for 9.4+ too.

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

* [Bug c++/94742] [8/9 Regression] Incorrect "no return statement" warning with [[noreturn]] and __FUNCTION__
  2020-04-24 10:12 [Bug c++/94742] New: Incorrect "no return statement" warning with [[noreturn]] and __FUNCTION__ didier.gcc at trosset dot fr
                   ` (5 preceding siblings ...)
  2020-09-17 17:37 ` jakub at gcc dot gnu.org
@ 2021-12-17  5:24 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-17  5:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gcc at sjor dot sg

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 81692 has been marked as a duplicate of this bug. ***

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

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

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-24 10:12 [Bug c++/94742] New: Incorrect "no return statement" warning with [[noreturn]] and __FUNCTION__ didier.gcc at trosset dot fr
2020-04-24 11:06 ` [Bug c++/94742] [8/9/10 Regression] " jakub at gcc dot gnu.org
2020-04-24 12:38 ` jakub at gcc dot gnu.org
2020-04-24 22:12 ` cvs-commit at gcc dot gnu.org
2020-04-24 22:24 ` [Bug c++/94742] [8/9 " jakub at gcc dot gnu.org
2020-09-16 19:20 ` cvs-commit at gcc dot gnu.org
2020-09-17 17:37 ` jakub at gcc dot gnu.org
2021-12-17  5:24 ` 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).