public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106596] New: Not a helpful diagnostic when putting things out of order in a member function
@ 2022-08-12 13:12 barry.revzin at gmail dot com
  2022-08-12 13:23 ` [Bug c++/106596] " mpolacek at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: barry.revzin at gmail dot com @ 2022-08-12 13:12 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106596
           Summary: Not a helpful diagnostic when putting things out of
                    order in a member function
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: barry.revzin at gmail dot com
  Target Milestone: ---

Consider this example:

template <class T> concept C = true;

template <class T>
struct Widget {
    void foo() requires C<T> noexcept;  
};

The issue here is that the noexcept needs to go before the requires clause, but
how many people really remember what the order of these things needs to be?

The gcc 12.1 error for this is:

<source>:5:25: error: expected ';' at end of member declaration
    5 |     void foo() requires C<T> noexcept;
      |                         ^~~~
      |                             ;
<source>:5:30: error: expected unqualified-id before 'noexcept'
    5 |     void foo() requires C<T> noexcept;
      |                              ^~~~~~~~

I suspect this might be a difficult thing to provide a diagnostic for, but this
particular one is pretty unhelpful. The first one is suggesting I needed to
write void foo() requires; which isn't even valid.

Hypothetical ideal:

<source>:5:30: error: the noexcept-specifier needs to precede the
requires-clause
    5 |     void foo() requires C<T> noexcept;
      |                ^~~~~~~~~~~~~ ^~~~~~~~
      |                noexcept requires C<T>;

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

* [Bug c++/106596] Not a helpful diagnostic when putting things out of order in a member function
  2022-08-12 13:12 [Bug c++/106596] New: Not a helpful diagnostic when putting things out of order in a member function barry.revzin at gmail dot com
@ 2022-08-12 13:23 ` mpolacek at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-08-12 13:23 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |diagnostic
                 CC|                            |mpolacek at gcc dot gnu.org
   Last reconfirmed|                            |2022-08-12

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.

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

end of thread, other threads:[~2022-08-12 13:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-12 13:12 [Bug c++/106596] New: Not a helpful diagnostic when putting things out of order in a member function barry.revzin at gmail dot com
2022-08-12 13:23 ` [Bug c++/106596] " mpolacek 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).