public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/112437] New: ICE with throw inside concept sometimes and -std=c++20
@ 2023-11-08  5:22 pinskia at gcc dot gnu.org
  2023-11-08  5:28 ` [Bug c++/112437] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-08  5:22 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112437
           Summary: ICE with throw inside concept sometimes and -std=c++20
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```

struct moveonly {};
template<class T>
concept Throwable = requires(T x) { throw x; };

bool a = Throwable<moveonly>;
```

This ICEs with `-std=c++20` but does not with `-std=c++17 -fconcepts`

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

* [Bug c++/112437] ICE with throw inside concept sometimes and -std=c++20
  2023-11-08  5:22 [Bug c++/112437] New: ICE with throw inside concept sometimes and -std=c++20 pinskia at gcc dot gnu.org
@ 2023-11-08  5:28 ` pinskia at gcc dot gnu.org
  2023-11-08  5:29 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-08  5:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Maybe related to:
https://gcc.gnu.org/legacy-ml/gcc-patches/2018-09/msg00226.html

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

* [Bug c++/112437] ICE with throw inside concept sometimes and -std=c++20
  2023-11-08  5:22 [Bug c++/112437] New: ICE with throw inside concept sometimes and -std=c++20 pinskia at gcc dot gnu.org
  2023-11-08  5:28 ` [Bug c++/112437] " pinskia at gcc dot gnu.org
@ 2023-11-08  5:29 ` pinskia at gcc dot gnu.org
  2023-11-08 12:00 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-08  5:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The backtrace:
```
t55.cc:4:37: internal compiler error: Segmentation fault
    4 | concept Throwable = requires(T x) { throw x; };
      |                                     ^~~~~~~
0x133b01f crash_signal
        /home/apinski/src/upstream-gcc-git/gcc/gcc/toplev.cc:316
0x7f18dce54def ???
       
/usr/src/debug/glibc-2.34-60.el9.x86_64/signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0xcf7fa2 treat_lvalue_as_rvalue_p(tree_node*, bool)
        /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/typeck.cc:10732
0xb5d62f build_throw(unsigned int, tree_node*)
        /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/except.cc:723
0xc70ede tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/pt.cc:20944
0xac70d3 tsubst_valid_expression_requirement
        /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/constraint.cc:1990
0xace475 tsubst_simple_requirement
        /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/constraint.cc:2024
0xace475 tsubst_requirement
        /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/constraint.cc:2221
0xace475 tsubst_requires_expr
        /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/constraint.cc:2351
0xacea6a tsubst_requires_expr(tree_node*, tree_node*, int, tree_node*)
        /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/constraint.cc:2370
0xc6fad5 tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/pt.cc:21472
0xacfc1e satisfy_atom
        /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/constraint.cc:3036
0xacfc1e satisfy_constraint_r
        /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/constraint.cc:3101
0xad0202 satisfy_normalized_constraints
        /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/constraint.cc:3126
0xacd3ce satisfy_nondeclaration_constraints
        /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/constraint.cc:3208
0xacd3ce constraint_satisfaction_value
        /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/constraint.cc:3373
0xad02e6 evaluate_concept_check(tree_node*)
        /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/constraint.cc:3421
0xab2f60 cxx_eval_constant_expression
        /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/constexpr.cc:8346
0xabc7d9 cxx_eval_outermost_constant_expr
        /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/constexpr.cc:8670
0xac2612 maybe_constant_init_1
        /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/constexpr.cc:9181
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

```

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

* [Bug c++/112437] ICE with throw inside concept sometimes and -std=c++20
  2023-11-08  5:22 [Bug c++/112437] New: ICE with throw inside concept sometimes and -std=c++20 pinskia at gcc dot gnu.org
  2023-11-08  5:28 ` [Bug c++/112437] " pinskia at gcc dot gnu.org
  2023-11-08  5:29 ` pinskia at gcc dot gnu.org
@ 2023-11-08 12:00 ` redi at gcc dot gnu.org
  2024-01-24  3:08 ` mpolacek at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2023-11-08 12:00 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-11-08

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

* [Bug c++/112437] ICE with throw inside concept sometimes and -std=c++20
  2023-11-08  5:22 [Bug c++/112437] New: ICE with throw inside concept sometimes and -std=c++20 pinskia at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-11-08 12:00 ` redi at gcc dot gnu.org
@ 2024-01-24  3:08 ` mpolacek at gcc dot gnu.org
  2024-02-01 14:00 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-01-24  3:08 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

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

* [Bug c++/112437] ICE with throw inside concept sometimes and -std=c++20
  2023-11-08  5:22 [Bug c++/112437] New: ICE with throw inside concept sometimes and -std=c++20 pinskia at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2024-01-24  3:08 ` mpolacek at gcc dot gnu.org
@ 2024-02-01 14:00 ` cvs-commit at gcc dot gnu.org
  2024-02-01 15:41 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-01 14:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:65b105b4f399559685200e1598ead8c7d0935c04

commit r14-8697-g65b105b4f399559685200e1598ead8c7d0935c04
Author: Marek Polacek <polacek@redhat.com>
Date:   Wed Jan 31 17:33:26 2024 -0500

    c++: ICE with throw inside concept [PR112437]

    We crash in the loop at the end of treat_lvalue_as_rvalue_p for code
    like

      template <class T>
      concept Throwable = requires(T x) { throw x; };

    because the code assumes that we eventually reach sk_function_parms or
    sk_try and bail, but in a concept we're in a sk_namespace.

    We're already checking sk_try so we don't crash in a function-try-block,
    but I've added a test anyway.

            PR c++/112437

    gcc/cp/ChangeLog:

            * typeck.cc (treat_lvalue_as_rvalue_p): Bail out on sk_namespace in
            the move on throw of parms loop.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/concepts-throw1.C: New test.
            * g++.dg/eh/throw4.C: New test.

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

* [Bug c++/112437] ICE with throw inside concept sometimes and -std=c++20
  2023-11-08  5:22 [Bug c++/112437] New: ICE with throw inside concept sometimes and -std=c++20 pinskia at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2024-02-01 14:00 ` cvs-commit at gcc dot gnu.org
@ 2024-02-01 15:41 ` cvs-commit at gcc dot gnu.org
  2024-02-01 15:50 ` cvs-commit at gcc dot gnu.org
  2024-02-01 15:56 ` mpolacek at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-01 15:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Marek Polacek
<mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:aa24f8f67fbff1c324c189b2bec9f58bd09f82dd

commit r13-8268-gaa24f8f67fbff1c324c189b2bec9f58bd09f82dd
Author: Marek Polacek <polacek@redhat.com>
Date:   Wed Jan 31 17:33:26 2024 -0500

    c++: ICE with throw inside concept [PR112437]

    We crash in the loop at the end of treat_lvalue_as_rvalue_p for code
    like

      template <class T>
      concept Throwable = requires(T x) { throw x; };

    because the code assumes that we eventually reach sk_function_parms or
    sk_try and bail, but in a concept we're in a sk_namespace.

    We're already checking sk_try so we don't crash in a function-try-block,
    but I've added a test anyway.

            PR c++/112437

    gcc/cp/ChangeLog:

            * typeck.cc (treat_lvalue_as_rvalue_p): Bail out on sk_namespace in
            the move on throw of parms loop.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/concepts-throw1.C: New test.
            * g++.dg/eh/throw4.C: New test.

    (cherry picked from commit 65b105b4f399559685200e1598ead8c7d0935c04)

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

* [Bug c++/112437] ICE with throw inside concept sometimes and -std=c++20
  2023-11-08  5:22 [Bug c++/112437] New: ICE with throw inside concept sometimes and -std=c++20 pinskia at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2024-02-01 15:41 ` cvs-commit at gcc dot gnu.org
@ 2024-02-01 15:50 ` cvs-commit at gcc dot gnu.org
  2024-02-01 15:56 ` mpolacek at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-01 15:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Marek Polacek
<mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:4617c9b6eb22062a319dcdbddb8c3cebce398c15

commit r12-10124-g4617c9b6eb22062a319dcdbddb8c3cebce398c15
Author: Marek Polacek <polacek@redhat.com>
Date:   Wed Jan 31 17:33:26 2024 -0500

    c++: ICE with throw inside concept [PR112437]

    We crash in the loop at the end of treat_lvalue_as_rvalue_p for code
    like

      template <class T>
      concept Throwable = requires(T x) { throw x; };

    because the code assumes that we eventually reach sk_function_parms or
    sk_try and bail, but in a concept we're in a sk_namespace.

    We're already checking sk_try so we don't crash in a function-try-block,
    but I've added a test anyway.

            PR c++/112437

    gcc/cp/ChangeLog:

            * typeck.cc (treat_lvalue_as_rvalue_p): Bail out on sk_namespace in
            the move on throw of parms loop.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/concepts-throw1.C: New test.
            * g++.dg/eh/throw4.C: New test.

    (cherry picked from commit 65b105b4f399559685200e1598ead8c7d0935c04)

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

* [Bug c++/112437] ICE with throw inside concept sometimes and -std=c++20
  2023-11-08  5:22 [Bug c++/112437] New: ICE with throw inside concept sometimes and -std=c++20 pinskia at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2024-02-01 15:50 ` cvs-commit at gcc dot gnu.org
@ 2024-02-01 15:56 ` mpolacek at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-02-01 15:56 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

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

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

end of thread, other threads:[~2024-02-01 15:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-08  5:22 [Bug c++/112437] New: ICE with throw inside concept sometimes and -std=c++20 pinskia at gcc dot gnu.org
2023-11-08  5:28 ` [Bug c++/112437] " pinskia at gcc dot gnu.org
2023-11-08  5:29 ` pinskia at gcc dot gnu.org
2023-11-08 12:00 ` redi at gcc dot gnu.org
2024-01-24  3:08 ` mpolacek at gcc dot gnu.org
2024-02-01 14:00 ` cvs-commit at gcc dot gnu.org
2024-02-01 15:41 ` cvs-commit at gcc dot gnu.org
2024-02-01 15:50 ` cvs-commit at gcc dot gnu.org
2024-02-01 15:56 ` 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).