public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101232] New: Bad error message with stray semicolon in initializer
@ 2021-06-27  9:50 tobi at gcc dot gnu.org
  2021-07-08  1:52 ` [Bug c++/101232] " tobi at gcc dot gnu.org
  2021-07-14  1:47 ` tobi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: tobi at gcc dot gnu.org @ 2021-06-27  9:50 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101232
           Summary: Bad error message with stray semicolon in initializer
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tobi at gcc dot gnu.org
  Target Milestone: ---

This example (Link to compiler explorer: -> https://godbolt.org/z/rxsreYs8Y
<-):

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

struct X {
    int a;
    int b;
};

void f() {
    auto x = X{ 1, 2; };
}
========================

Gives the fairly misleading error message

<source>: In function 'void f()':
<source>:7:15: error: expected primary-expression before '{' token
    7 |     auto x = X{ 1, 2; };
      |               ^

The error message is of the same kind all the way from GCC 4.1.2 up to the
current trunk.

For comparison, clang gives the much more helpful
<source>:7:21: error: unexpected ';' before '}'
    auto x = X{ 1, 2; };
                    ^

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

end of thread, other threads:[~2021-07-14  1:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-27  9:50 [Bug c++/101232] New: Bad error message with stray semicolon in initializer tobi at gcc dot gnu.org
2021-07-08  1:52 ` [Bug c++/101232] " tobi at gcc dot gnu.org
2021-07-14  1:47 ` tobi 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).