Bug 111106 - [11/12/13/14/15 Regression] missing ; causes internal compiler error: in dependent_type_p, at cp/pt.cc:27901
Summary: [11/12/13/14/15 Regression] missing ; causes internal compiler error: in depe...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P5 trivial
Target Milestone: 15.0
Assignee: Simon Martin
URL:
Keywords: error-recovery, ice-checking, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2023-08-22 21:12 UTC by Marek Polacek
Modified: 2024-06-10 15:00 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2024-05-24 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Polacek 2023-08-22 21:12:23 UTC
consteval int id (int i) { return i; }

constexpr int
f (auto i) requires requires { id (i) }
{
  return i;
}

void
g ()
{
  f (42);
}

$ ./cc1plus -quiet -std=c++23 ice.C
ice.C:4:38: error: expected ‘;’ before ‘}’ token
    4 | f (auto i) requires requires { id (i) }
      |                                      ^~
      |                                      ;
ice.C:4:1: error: constraints on a non-templated function
    4 | f (auto i) requires requires { id (i) }
      | ^
ice.C:4:39: internal compiler error: in dependent_type_p, at cp/pt.cc:27901
    4 | f (auto i) requires requires { id (i) }
      |                                       ^
0x10bfe18 dependent_type_p(tree_node*)
	/home/mpolacek/src/gcc/gcc/cp/pt.cc:27901
0xe71b20 require_complete_types_for_parms
	/home/mpolacek/src/gcc/gcc/cp/decl.cc:14908
0xe7c9eb check_function_type
	/home/mpolacek/src/gcc/gcc/cp/decl.cc:17236
0xe7dd74 start_preparsed_function(tree_node*, tree_node*, int)
	/home/mpolacek/src/gcc/gcc/cp/decl.cc:17435
0xe8098b start_function(cp_decl_specifier_seq*, cp_declarator const*, tree_node*)
	/home/mpolacek/src/gcc/gcc/cp/decl.cc:17759
0xff3994 cp_parser_function_definition_from_specifiers_and_declarator
	/home/mpolacek/src/gcc/gcc/cp/parser.cc:31935
0xfe06bc cp_parser_init_declarator
	/home/mpolacek/src/gcc/gcc/cp/parser.cc:22827
0xfd2054 cp_parser_simple_declaration
	/home/mpolacek/src/gcc/gcc/cp/parser.cc:15435
0xfd1bcd cp_parser_block_declaration
	/home/mpolacek/src/gcc/gcc/cp/parser.cc:15255
0xfd1816 cp_parser_declaration
	/home/mpolacek/src/gcc/gcc/cp/parser.cc:15121
0xfd18f6 cp_parser_toplevel_declaration
	/home/mpolacek/src/gcc/gcc/cp/parser.cc:15142
0xfb98ac cp_parser_translation_unit
	/home/mpolacek/src/gcc/gcc/cp/parser.cc:5140
0x102d32f c_parse_file()
	/home/mpolacek/src/gcc/gcc/cp/parser.cc:49810
0x122af79 c_common_parse_file()
	/home/mpolacek/src/gcc/gcc/c-family/c-opts.cc:1257
Comment 1 Marek Polacek 2023-08-22 21:14:20 UTC
With s/consteval/contexpr/ ICEs since GCC 10.
Comment 2 Marek Polacek 2023-08-22 21:15:18 UTC
(In reply to Marek Polacek from comment #1)
> With s/consteval/contexpr/ ICEs since GCC 10.

constexpr
Comment 3 Simon Martin 2024-05-24 14:45:48 UTC
Working on it
Comment 4 GCC Commits 2024-06-04 15:13:41 UTC
The master branch has been updated by Simon Martin <simartin@gcc.gnu.org>:

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

commit r15-1016-gcfbd8735359d84a2d716549415eac70e885167bf
Author: Simon Martin <simon@nasilyan.com>
Date:   Fri May 24 17:00:17 2024 +0200

    Fix PR c++/111106: missing ; causes internal compiler error
    
    We currently fail upon the following because an assert in dependent_type_p
    fails for f's parameter
    
    === cut here ===
    consteval int id (int i) { return i; }
    constexpr int
    f (auto i) requires requires { id (i) } { return i; }
    void g () { f (42); }
    === cut here ===
    
    This patch fixes this by relaxing the assert to pass during error recovery.
    
    Successfully tested on x86_64-pc-linux-gnu.
    
            PR c++/111106
    
    gcc/cp/ChangeLog:
    
            * pt.cc (dependent_type_p): Don't fail assert during error recovery.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp2a/consteval37.C: New test.
Comment 5 Simon Martin 2024-06-04 15:16:34 UTC
Fixed in trunk