public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105222] New: gcc rejects valid syntax of ternary operator for lambda in requires clause
@ 2022-04-11 14:38 hewillk at gmail dot com
  2022-04-11 14:39 ` [Bug c++/105222] " hewillk at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: hewillk at gmail dot com @ 2022-04-11 14:38 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105222
           Summary: gcc rejects valid syntax of ternary operator for
                    lambda in requires clause
           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() {
  auto b = requires { true ? [] {} : [] {}; };
}

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

* [Bug c++/105222] gcc rejects valid syntax of ternary operator for lambda in requires clause
  2022-04-11 14:38 [Bug c++/105222] New: gcc rejects valid syntax of ternary operator for lambda in requires clause hewillk at gmail dot com
@ 2022-04-11 14:39 ` hewillk at gmail dot com
  2022-04-11 14:41 ` hewillk at gmail dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: hewillk at gmail dot com @ 2022-04-11 14:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from 康桓瑋 <hewillk at gmail dot com> ---
gcc rejects this valid syntax with

source>:2:32: error: expected ':' before '{' token
    2 |   auto b = requires { true ? [] {} : [] {}; };
      |                                ^~
      |                                :
<source>:2:33: error: expected primary-expression before '{' token
    2 |   auto b = requires { true ? [] {} : [] {}; };
      |                                 ^
<source>:2:35: error: expected ';' before ':' token
    2 |   auto b = requires { true ? [] {} : [] {}; };
      |                                   ^~
      |                                   ;

https://godbolt.org/z/4c3PPb5Pb

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

* [Bug c++/105222] gcc rejects valid syntax of ternary operator for lambda in requires clause
  2022-04-11 14:38 [Bug c++/105222] New: gcc rejects valid syntax of ternary operator for lambda in requires clause hewillk at gmail dot com
  2022-04-11 14:39 ` [Bug c++/105222] " hewillk at gmail dot com
@ 2022-04-11 14:41 ` hewillk at gmail dot com
  2022-04-11 14:46 ` hewillk at gmail dot com
  2022-04-11 16:22 ` [Bug c++/105222] gcc totally broken with " hewillk at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: hewillk at gmail dot com @ 2022-04-11 14:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from 康桓瑋 <hewillk at gmail dot com> ---
And gcc accepts the following invalid syntax:

int main() {
  auto b = requires { true ? [] : [] {}; };
}

https://godbolt.org/z/xeE1oYs1Y

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

* [Bug c++/105222] gcc rejects valid syntax of ternary operator for lambda in requires clause
  2022-04-11 14:38 [Bug c++/105222] New: gcc rejects valid syntax of ternary operator for lambda in requires clause hewillk at gmail dot com
  2022-04-11 14:39 ` [Bug c++/105222] " hewillk at gmail dot com
  2022-04-11 14:41 ` hewillk at gmail dot com
@ 2022-04-11 14:46 ` hewillk at gmail dot com
  2022-04-11 16:22 ` [Bug c++/105222] gcc totally broken with " hewillk at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: hewillk at gmail dot com @ 2022-04-11 14:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from 康桓瑋 <hewillk at gmail dot com> ---
(In reply to 康桓瑋 from comment #2)
> And gcc accepts the following invalid syntax:
> 
> int main() {
>   auto b = requires { true ? [] : [] {}; };
> }
> 
> https://godbolt.org/z/xeE1oYs1Y

It seems like the single [] makes gcc totally broken.

int main() {
  auto b = requires { true ? [] : []!-!-[]?[]; };
}

https://godbolt.org/z/EPTE6zf5E

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

* [Bug c++/105222] gcc totally broken with ternary operator for lambda in requires clause
  2022-04-11 14:38 [Bug c++/105222] New: gcc rejects valid syntax of ternary operator for lambda in requires clause hewillk at gmail dot com
                   ` (2 preceding siblings ...)
  2022-04-11 14:46 ` hewillk at gmail dot com
@ 2022-04-11 16:22 ` hewillk at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: hewillk at gmail dot com @ 2022-04-11 16:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from 康桓瑋 <hewillk at gmail dot com> ---
maybe dup of PR99546.

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

end of thread, other threads:[~2022-04-11 16:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-11 14:38 [Bug c++/105222] New: gcc rejects valid syntax of ternary operator for lambda in requires clause hewillk at gmail dot com
2022-04-11 14:39 ` [Bug c++/105222] " hewillk at gmail dot com
2022-04-11 14:41 ` hewillk at gmail dot com
2022-04-11 14:46 ` hewillk at gmail dot com
2022-04-11 16:22 ` [Bug c++/105222] gcc totally broken with " hewillk at gmail dot com

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).