public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/108576] New: False positive for -Werror=return-type
@ 2023-01-27 19:32 sergey at polovko dot me
  2023-01-27 19:38 ` [Bug c++/108576] " sergey at polovko dot me
  2023-01-27 19:39 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: sergey at polovko dot me @ 2023-01-27 19:32 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108576
           Summary: False positive for -Werror=return-type
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sergey at polovko dot me
  Target Milestone: ---

Starting from GCC 12.1 I see changed compiler behaviour for following snippet
of code:

struct S {
    ~S() {}
};

int func() {
    if (auto s = S{}; false) {
    } else {
        return 1;
    }
}

From GCC 7.1 to 11.3 this snippet of compiled just fine:
 * https://godbolt.org/z/Yb787e6cs (7.1)
 * https://godbolt.org/z/8Gq4fjacr (12.3)

But starting from GCC 12 it produces a warning:
 * https://godbolt.org/z/MvoTcb7aW (12.1)
 * https://godbolt.org/z/dvqebv7KG (trunk)

$ g++ -std=c++17 -Werror=return-type

<source>: In function 'int func()':
<source>:10:1: error: control reaches end of non-void function
[-Werror=return-type]
   10 | }
      | ^
cc1plus: some warnings being treated as errors
Compiler returned: 1


The issue appears only with default or -O0 optimization level. With -O1 there
is no warnings:
 * https://godbolt.org/z/Pxv1Ms5ez

$ g++ -std=c++17 -O1 -Werror=return-type

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

* [Bug c++/108576] False positive for -Werror=return-type
  2023-01-27 19:32 [Bug c++/108576] New: False positive for -Werror=return-type sergey at polovko dot me
@ 2023-01-27 19:38 ` sergey at polovko dot me
  2023-01-27 19:39 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: sergey at polovko dot me @ 2023-01-27 19:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Sergey Polovko <sergey at polovko dot me> ---
Sorry, this line
>  * https://godbolt.org/z/8Gq4fjacr (12.3)

should mention GCC 11.3

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

* [Bug c++/108576] False positive for -Werror=return-type
  2023-01-27 19:32 [Bug c++/108576] New: False positive for -Werror=return-type sergey at polovko dot me
  2023-01-27 19:38 ` [Bug c++/108576] " sergey at polovko dot me
@ 2023-01-27 19:39 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-27 19:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 104787.

*** This bug has been marked as a duplicate of bug 104787 ***

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

end of thread, other threads:[~2023-01-27 19:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-27 19:32 [Bug c++/108576] New: False positive for -Werror=return-type sergey at polovko dot me
2023-01-27 19:38 ` [Bug c++/108576] " sergey at polovko dot me
2023-01-27 19:39 ` 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).