public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110065] New: auto in template argument causes ICE, also accepts-invalid
@ 2023-05-31 18:19 stevenxia990430 at gmail dot com
  2023-05-31 21:54 ` [Bug c++/110065] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: stevenxia990430 at gmail dot com @ 2023-05-31 18:19 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110065
           Summary: auto in template argument causes ICE, also
                    accepts-invalid
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stevenxia990430 at gmail dot com
  Target Milestone: ---

The following program produces internal compiler error: Segmentation fault.
Tested on GCC-trunk

To quickly reproduce: https://gcc.godbolt.org/z/noY1qxK91
```
#include <type_traits>
#include <iostream>
auto main() -> int
{
    std::cout << std::is_scoped_enum_v<auto(&)(const int*) -> auto&>;
    return EXIT_SUCCESS;
}
```

Note, if we remove the std::cout and produce the following code:
```
#include <type_traits>
#include <iostream>
auto main() -> int
{
    std::is_scoped_enum_v<auto(&)(const int*) -> auto&>;
    return EXIT_SUCCESS;
}
```
gcc compiles without any error, however this code is rejected by Clang (tested
on Clang-trunk)

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

* [Bug c++/110065] auto in template argument causes ICE, also accepts-invalid
  2023-05-31 18:19 [Bug c++/110065] New: auto in template argument causes ICE, also accepts-invalid stevenxia990430 at gmail dot com
@ 2023-05-31 21:54 ` pinskia at gcc dot gnu.org
  2023-05-31 21:56 ` [Bug c++/110065] [11/12/13/14 Regression] [C++20/2b] " 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-05-31 21:54 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2023-05-31
           Keywords|                            |accepts-invalid,
                   |                            |ice-on-invalid-code

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reduced testcase:
```
template <typename a>
inline constexpr bool t = false;

int main()
{
    return t<auto(&)(const int*) -> auto&>;
}
```
If we `s/return//` we get the accept invalid too.

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

* [Bug c++/110065] [11/12/13/14 Regression] [C++20/2b] auto in template argument causes ICE, also accepts-invalid
  2023-05-31 18:19 [Bug c++/110065] New: auto in template argument causes ICE, also accepts-invalid stevenxia990430 at gmail dot com
  2023-05-31 21:54 ` [Bug c++/110065] " pinskia at gcc dot gnu.org
@ 2023-05-31 21:56 ` pinskia at gcc dot gnu.org
  2024-01-10 15:53 ` [Bug c++/110065] [11/12/13/14 Regression] [C++20/2b] auto return type " jamborm at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-31 21:56 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |11.3.0, 12.1.0
            Summary|[C++20/2b] auto in template |[11/12/13/14 Regression]
                   |argument causes ICE, also   |[C++20/2b] auto in template
                   |accepts-invalid             |argument causes ICE, also
                   |                            |accepts-invalid
      Known to work|                            |11.1.0, 11.2.0
   Target Milestone|---                         |12.4

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

* [Bug c++/110065] [11/12/13/14 Regression] [C++20/2b] auto return type in template argument causes ICE, also accepts-invalid
  2023-05-31 18:19 [Bug c++/110065] New: auto in template argument causes ICE, also accepts-invalid stevenxia990430 at gmail dot com
  2023-05-31 21:54 ` [Bug c++/110065] " pinskia at gcc dot gnu.org
  2023-05-31 21:56 ` [Bug c++/110065] [11/12/13/14 Regression] [C++20/2b] " pinskia at gcc dot gnu.org
@ 2024-01-10 15:53 ` jamborm at gcc dot gnu.org
  2024-01-11 23:28 ` mpolacek at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jamborm at gcc dot gnu.org @ 2024-01-10 15:53 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Jambor <jamborm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jamborm at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org
           Keywords|needs-bisection             |

--- Comment #2 from Martin Jambor <jamborm at gcc dot gnu.org> ---
The ICE when compiling the reduced testcase from comment #1 started with
r14-1659-gd3e2a174b13dd0 (Jason Merrill: c++: diagnose auto in template arg) -
before that it was an error.

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

* [Bug c++/110065] [11/12/13/14 Regression] [C++20/2b] auto return type in template argument causes ICE, also accepts-invalid
  2023-05-31 18:19 [Bug c++/110065] New: auto in template argument causes ICE, also accepts-invalid stevenxia990430 at gmail dot com
                   ` (2 preceding siblings ...)
  2024-01-10 15:53 ` [Bug c++/110065] [11/12/13/14 Regression] [C++20/2b] auto return type " jamborm at gcc dot gnu.org
@ 2024-01-11 23:28 ` mpolacek at gcc dot gnu.org
  2024-01-12 13:46 ` mpolacek 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-11 23:28 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I think we need to bring the check back into cp_parser_template_type_arg;
parser->auto_is_implicit_function_template_parm_p is false here so we won't
pedwarn.

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

* [Bug c++/110065] [11/12/13/14 Regression] [C++20/2b] auto return type in template argument causes ICE, also accepts-invalid
  2023-05-31 18:19 [Bug c++/110065] New: auto in template argument causes ICE, also accepts-invalid stevenxia990430 at gmail dot com
                   ` (3 preceding siblings ...)
  2024-01-11 23:28 ` mpolacek at gcc dot gnu.org
@ 2024-01-12 13:46 ` mpolacek at gcc dot gnu.org
  2024-01-12 14:05 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-01-12 13:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           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++/110065] [11/12/13/14 Regression] [C++20/2b] auto return type in template argument causes ICE, also accepts-invalid
  2023-05-31 18:19 [Bug c++/110065] New: auto in template argument causes ICE, also accepts-invalid stevenxia990430 at gmail dot com
                   ` (4 preceding siblings ...)
  2024-01-12 13:46 ` mpolacek at gcc dot gnu.org
@ 2024-01-12 14:05 ` rguenth at gcc dot gnu.org
  2024-01-15 19:50 ` mpolacek at gcc dot gnu.org
  2024-01-15 23:40 ` cvs-commit at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-01-12 14:05 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug c++/110065] [11/12/13/14 Regression] [C++20/2b] auto return type in template argument causes ICE, also accepts-invalid
  2023-05-31 18:19 [Bug c++/110065] New: auto in template argument causes ICE, also accepts-invalid stevenxia990430 at gmail dot com
                   ` (5 preceding siblings ...)
  2024-01-12 14:05 ` rguenth at gcc dot gnu.org
@ 2024-01-15 19:50 ` mpolacek at gcc dot gnu.org
  2024-01-15 23:40 ` cvs-commit at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-01-15 19:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
With -std=c++20 the ICE started with r12-4772.

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

* [Bug c++/110065] [11/12/13/14 Regression] [C++20/2b] auto return type in template argument causes ICE, also accepts-invalid
  2023-05-31 18:19 [Bug c++/110065] New: auto in template argument causes ICE, also accepts-invalid stevenxia990430 at gmail dot com
                   ` (6 preceding siblings ...)
  2024-01-15 19:50 ` mpolacek at gcc dot gnu.org
@ 2024-01-15 23:40 ` cvs-commit at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-15 23:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 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:a3054489117085c095e480c71b6aaeea9a463c37

commit r14-7264-ga3054489117085c095e480c71b6aaeea9a463c37
Author: Marek Polacek <polacek@redhat.com>
Date:   Mon Jan 15 09:15:59 2024 -0500

    c++: ICE with auto in template arg [PR110065]

    Here we started crashing with r14-1659 because that removed the
    auto checking in cp_parser_template_type_arg which seemed like
    dead code.  But the attached test shows that the code can still
    be reached because cp_parser_type_id_1 checks auto only when
    auto_is_implicit_function_template_parm_p is on.

    Then I noticed that we're still crashing in C++20, and that ICE
    started with r12-4772.  So I changed the reemerged check to use
    flag_concepts_ts rather than flag_concepts on the basis that
    check_auto_in_tmpl_args also checks flag_concepts_ts.

            PR c++/110065

    gcc/cp/ChangeLog:

            * parser.cc (cp_parser_template_type_arg): Add auto checking.

    gcc/testsuite/ChangeLog:

            * g++.dg/concepts/auto8.C: New test.
            * g++.dg/concepts/auto8a.C: New test.

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

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

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-31 18:19 [Bug c++/110065] New: auto in template argument causes ICE, also accepts-invalid stevenxia990430 at gmail dot com
2023-05-31 21:54 ` [Bug c++/110065] " pinskia at gcc dot gnu.org
2023-05-31 21:56 ` [Bug c++/110065] [11/12/13/14 Regression] [C++20/2b] " pinskia at gcc dot gnu.org
2024-01-10 15:53 ` [Bug c++/110065] [11/12/13/14 Regression] [C++20/2b] auto return type " jamborm at gcc dot gnu.org
2024-01-11 23:28 ` mpolacek at gcc dot gnu.org
2024-01-12 13:46 ` mpolacek at gcc dot gnu.org
2024-01-12 14:05 ` rguenth at gcc dot gnu.org
2024-01-15 19:50 ` mpolacek at gcc dot gnu.org
2024-01-15 23:40 ` cvs-commit 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).