public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/103653] New: GCC rejected int x = 0;  auto(x); in C++23
@ 2021-12-10 17:09 hewillk at gmail dot com
  2021-12-10 17:13 ` [Bug c++/103653] " hewillk at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: hewillk at gmail dot com @ 2021-12-10 17:09 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103653
           Summary: GCC rejected int x = 0;  auto(x); in C++23
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

int main() {
  int x = 0;
  auto(x);
}

Should this work? GCC rejects it with:
<source>:3:3: error: declaration of 'auto x' has no initializer
    3 |   auto(x);
      |   ^~~~
Isn't this using auto to decay-copy the variable x? Please correct me if I am
wrong.

https://godbolt.org/z/TxorTr56o

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

* [Bug c++/103653] GCC rejected int x = 0;  auto(x); in C++23
  2021-12-10 17:09 [Bug c++/103653] New: GCC rejected int x = 0; auto(x); in C++23 hewillk at gmail dot com
@ 2021-12-10 17:13 ` hewillk at gmail dot com
  2021-12-25 16:05 ` hewillk at gmail dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: hewillk at gmail dot com @ 2021-12-10 17:13 UTC (permalink / raw)
  To: gcc-bugs

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

康桓瑋 <hewillk at gmail dot com> changed:

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

--- Comment #1 from 康桓瑋 <hewillk at gmail dot com> ---
Oh, should be +auto(x);

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

* [Bug c++/103653] GCC rejected int x = 0;  auto(x); in C++23
  2021-12-10 17:09 [Bug c++/103653] New: GCC rejected int x = 0; auto(x); in C++23 hewillk at gmail dot com
  2021-12-10 17:13 ` [Bug c++/103653] " hewillk at gmail dot com
@ 2021-12-25 16:05 ` hewillk at gmail dot com
  2021-12-25 21:58 ` pinskia at gcc dot gnu.org
  2021-12-26 10:02 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: hewillk at gmail dot com @ 2021-12-25 16:05 UTC (permalink / raw)
  To: gcc-bugs

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

康桓瑋 <hewillk at gmail dot com> changed:

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

--- Comment #2 from 康桓瑋 <hewillk at gmail dot com> ---
(In reply to 康桓瑋 from comment #1)
> Oh, should be +auto(x);

But I think auto(x) should also be well-formed.

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

* [Bug c++/103653] GCC rejected int x = 0;  auto(x); in C++23
  2021-12-10 17:09 [Bug c++/103653] New: GCC rejected int x = 0; auto(x); in C++23 hewillk at gmail dot com
  2021-12-10 17:13 ` [Bug c++/103653] " hewillk at gmail dot com
  2021-12-25 16:05 ` hewillk at gmail dot com
@ 2021-12-25 21:58 ` pinskia at gcc dot gnu.org
  2021-12-26 10:02 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-25 21:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>But I think auto(x) should also be well-formed.

it is well formed as a declaration.
  auto(x) = 1;

Unless something changed in that part of C++ standard too.


The following does work as expected too:
int main() {
  int x = 0;
  float t;
  t = auto(x);
}

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

* [Bug c++/103653] GCC rejected int x = 0;  auto(x); in C++23
  2021-12-10 17:09 [Bug c++/103653] New: GCC rejected int x = 0; auto(x); in C++23 hewillk at gmail dot com
                   ` (2 preceding siblings ...)
  2021-12-25 21:58 ` pinskia at gcc dot gnu.org
@ 2021-12-26 10:02 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2021-12-26 10:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Yes this changed in C++23 so auto(X) creates an rvalue of the decayed type of
x.

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

end of thread, other threads:[~2021-12-26 10:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-10 17:09 [Bug c++/103653] New: GCC rejected int x = 0; auto(x); in C++23 hewillk at gmail dot com
2021-12-10 17:13 ` [Bug c++/103653] " hewillk at gmail dot com
2021-12-25 16:05 ` hewillk at gmail dot com
2021-12-25 21:58 ` pinskia at gcc dot gnu.org
2021-12-26 10:02 ` redi 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).