public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95559] New: Compiling "{{}}" result is inconsistent in different versions
@ 2020-06-06  4:11 haoxintu at gmail dot com
  2020-06-09 22:41 ` [Bug c++/95559] GCC fails to compile "{{}}" in some versions mpolacek at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: haoxintu at gmail dot com @ 2020-06-06  4:11 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95559
           Summary: Compiling "{{}}" result is inconsistent in different
                    versions
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This case test.cc

#include<iostream>
int main() {
    return {{}};
}

In the version of GCC 6.1 - 8.4, it's compiled ok.

But in GCC 6.1 lower and 8.4 higher version, for example, in GCC trunk

$g++-trunk test.cc 
test.cc: In function 'int main()':
test.cc:3:15: error: too many braces around scalar initializer for type 'int'
    3 |     int var = {{}};
      | 

I also compiled test.cc in recent released Clang, and they all accept "{{}}".

Should GCC compile "{{}}" fine also? I think this is a supported feature
according to https://en.cppreference.com/w/cpp/language/return.

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

* [Bug c++/95559] GCC fails to compile "{{}}" in some versions
  2020-06-06  4:11 [Bug c++/95559] New: Compiling "{{}}" result is inconsistent in different versions haoxintu at gmail dot com
@ 2020-06-09 22:41 ` mpolacek at gcc dot gnu.org
  2020-06-09 23:36 ` haoxintu at gmail dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-06-09 22:41 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I can't find a version of GCC that compiled this.  And clang++ emits a warning:

warning: too many braces around scalar initializer
[-Wmany-braces-around-scalar-init]

I don't think this is rejects-valid.

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

* [Bug c++/95559] GCC fails to compile "{{}}" in some versions
  2020-06-06  4:11 [Bug c++/95559] New: Compiling "{{}}" result is inconsistent in different versions haoxintu at gmail dot com
  2020-06-09 22:41 ` [Bug c++/95559] GCC fails to compile "{{}}" in some versions mpolacek at gcc dot gnu.org
@ 2020-06-09 23:36 ` haoxintu at gmail dot com
  2020-06-09 23:39 ` haoxintu at gmail dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: haoxintu at gmail dot com @ 2020-06-09 23:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Haoxin Tu <haoxintu at gmail dot com> ---
(In reply to Marek Polacek from comment #1)
> I can't find a version of GCC that compiled this.  

Hi, so sorry I might use the wrong test case. Please try this case bug.cc
instead

#include <iostream>
int main(){
    int a = {{}};
    std::cout << a << std::endl;
    return 0;
}

In godbolt https://godbolt.org/z/K_drKC .

Also, in my machine,

$g++-8 test.cc ; ./a.out
0

$g++-8 --version
g++-8 (Ubuntu 8.4.0-1ubuntu1~18.04) 8.4.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$g++-trunk bug.cc
bug.cc: In function ‘int main()’:
bug.cc:3:16: error: too many braces around scalar initializer for type ‘int’
    3 |     int a = {{}};
      |  

$g++-trunk --version
g++ (GCC) 11.0.0 20200526 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

> I don't think this is rejects-valid.

I guess clang might have some issue in compiling "{{}}", clang accepts this
code but icc or msvc reject.

Please take a look at above situation, thanks ~

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

* [Bug c++/95559] GCC fails to compile "{{}}" in some versions
  2020-06-06  4:11 [Bug c++/95559] New: Compiling "{{}}" result is inconsistent in different versions haoxintu at gmail dot com
  2020-06-09 22:41 ` [Bug c++/95559] GCC fails to compile "{{}}" in some versions mpolacek at gcc dot gnu.org
  2020-06-09 23:36 ` haoxintu at gmail dot com
@ 2020-06-09 23:39 ` haoxintu at gmail dot com
  2020-06-10 13:26 ` [Bug c++/95559] GCC accepts "too many braces around scalar initializer " in the version of 6.1 - 8.4 mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: haoxintu at gmail dot com @ 2020-06-09 23:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Haoxin Tu <haoxintu at gmail dot com> ---
(In reply to Haoxin Tu from comment #2)
> $g++-8 test.cc ; ./a.out
> 0

Here is 

> $g++-8 bug.cc ; ./a.out
> 0

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

* [Bug c++/95559] GCC accepts "too many braces around scalar initializer " in the version of 6.1 - 8.4
  2020-06-06  4:11 [Bug c++/95559] New: Compiling "{{}}" result is inconsistent in different versions haoxintu at gmail dot com
                   ` (2 preceding siblings ...)
  2020-06-09 23:39 ` haoxintu at gmail dot com
@ 2020-06-10 13:26 ` mpolacek at gcc dot gnu.org
  2020-06-10 13:33 ` haoxintu at gmail dot com
  2020-06-10 13:34 ` mpolacek at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-06-10 13:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
That's the same case, initializing an int with {{}}.  GCC 8 compiled the second
testcase, but that was fixed in r269045.

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

* [Bug c++/95559] GCC accepts "too many braces around scalar initializer " in the version of 6.1 - 8.4
  2020-06-06  4:11 [Bug c++/95559] New: Compiling "{{}}" result is inconsistent in different versions haoxintu at gmail dot com
                   ` (3 preceding siblings ...)
  2020-06-10 13:26 ` [Bug c++/95559] GCC accepts "too many braces around scalar initializer " in the version of 6.1 - 8.4 mpolacek at gcc dot gnu.org
@ 2020-06-10 13:33 ` haoxintu at gmail dot com
  2020-06-10 13:34 ` mpolacek at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: haoxintu at gmail dot com @ 2020-06-10 13:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Haoxin Tu <haoxintu at gmail dot com> ---
(In reply to Marek Polacek from comment #4)
> That's the same case, initializing an int with {{}}.  GCC 8 compiled the
> second testcase, but that was fixed in r269045.

Ok, got it. At least this was a bug, can you change the status to DUPLICATE if
you are convenience? Thank you so much~

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

* [Bug c++/95559] GCC accepts "too many braces around scalar initializer " in the version of 6.1 - 8.4
  2020-06-06  4:11 [Bug c++/95559] New: Compiling "{{}}" result is inconsistent in different versions haoxintu at gmail dot com
                   ` (4 preceding siblings ...)
  2020-06-10 13:33 ` haoxintu at gmail dot com
@ 2020-06-10 13:34 ` mpolacek at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-06-10 13:34 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|INVALID                     |DUPLICATE

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


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

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

end of thread, other threads:[~2020-06-10 13:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-06  4:11 [Bug c++/95559] New: Compiling "{{}}" result is inconsistent in different versions haoxintu at gmail dot com
2020-06-09 22:41 ` [Bug c++/95559] GCC fails to compile "{{}}" in some versions mpolacek at gcc dot gnu.org
2020-06-09 23:36 ` haoxintu at gmail dot com
2020-06-09 23:39 ` haoxintu at gmail dot com
2020-06-10 13:26 ` [Bug c++/95559] GCC accepts "too many braces around scalar initializer " in the version of 6.1 - 8.4 mpolacek at gcc dot gnu.org
2020-06-10 13:33 ` haoxintu at gmail dot com
2020-06-10 13:34 ` 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).