public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/103480] New: [10,11,12]Werror=useless-cast with constexpr destructor
@ 2021-11-29 22:51 peeceseven at gmail dot com
  2021-11-29 23:06 ` [Bug c++/103480] -Werror=useless-cast " mpolacek at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: peeceseven at gmail dot com @ 2021-11-29 22:51 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103480
           Summary: [10,11,12]Werror=useless-cast with constexpr
                    destructor
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: peeceseven at gmail dot com
  Target Milestone: ---

Created attachment 51901
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51901&action=edit
sample that causes the bug.

https://godbolt.org/z/vsdd6M6cc

Issue: useless cast error triggers somehow when we have a constexpr destructor.

GCC 9 doesn't support c++20's constexpr destructor. But this problem exists in
10,11,12, and trunk.

Code compiles on clang and msvc.



//error output
<source>: In instantiation of 'static constexpr auto scope_guard::array(void
(*)()) [with long unsigned int count = 2]':
<source>:82:45:   required from here
<source>:69:12:   in 'constexpr' expansion of 'std::array<scope_guard, 2>(r)'
<source>:69:12: error: useless cast to type 'struct scope_guard&&'
[-Werror=useless-cast]
   69 |     return r;
      |            ^
<source>: In function 'int main()':
<source>:82:51:   in 'constexpr' expansion of 'scope_guard::array(void (*)())
[with long unsigned int count = 2]()'
<source>:69:12:   in 'constexpr' expansion of 'std::array<scope_guard, 2>(r)'
<source>:82:51: error: useless cast to type 'struct scope_guard&&'
[-Werror=useless-cast]
   82 |     constexpr auto t = scope_guard::array<2>(&test);
      |                                                   ^
<source>:82:51:   in 'constexpr' expansion of 'scope_guard::array(void (*)())
[with long unsigned int count = 2]()'
<source>:69:12:   in 'constexpr' expansion of 'std::array<scope_guard, 2>(r)'
<source>:82:51: error: useless cast to type 'struct scope_guard&&'
[-Werror=useless-cast]
cc1plus: some warnings being treated as errors
Compiler returned: 1

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

end of thread, other threads:[~2022-05-10 10:14 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-29 22:51 [Bug c++/103480] New: [10,11,12]Werror=useless-cast with constexpr destructor peeceseven at gmail dot com
2021-11-29 23:06 ` [Bug c++/103480] -Werror=useless-cast " mpolacek at gcc dot gnu.org
2021-11-30  0:11 ` mpolacek at gcc dot gnu.org
2021-11-30  0:46 ` [Bug c++/103480] [10/11/12 Regression] " mpolacek at gcc dot gnu.org
2021-11-30  0:52 ` mpolacek at gcc dot gnu.org
2021-12-30 17:49 ` jakub at gcc dot gnu.org
2022-01-12  8:49 ` cvs-commit at gcc dot gnu.org
2022-01-12  8:53 ` [Bug c++/103480] [10/11 " jakub at gcc dot gnu.org
2022-01-24  9:21 ` cvs-commit at gcc dot gnu.org
2022-01-24  9:28 ` [Bug c++/103480] [10 " jakub at gcc dot gnu.org
2022-05-10  8:22 ` cvs-commit at gcc dot gnu.org
2022-05-10 10:14 ` jakub 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).