Bug 84551 - [8 Regression] [concepts] Compiler options "-O -g" cause valid code to be rejected
Summary: [8 Regression] [concepts] Compiler options "-O -g" cause valid code to be rej...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.0
: P1 normal
Target Milestone: 8.0
Assignee: Jason Merrill
URL:
Keywords: ice-on-valid-code, rejects-valid
Depends on:
Blocks: concepts
  Show dependency treegraph
 
Reported: 2018-02-25 13:23 UTC by Volker Reichelt
Modified: 2018-02-26 19:09 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-02-26 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2018-02-25 13:23:39 UTC
The following valid code snippet (compiled with "-fconcepts -g -O")
is wrongly rejected and triggers an ICE on trunk:

===================================================================
template<typename> concept bool C() { return true; }

template<template<typename T> requires C<T>() class> struct A {};

template<typename> requires true struct B {};

A<B> a;
===================================================================

bug.cc: In function 'concept bool C()':
bug.cc:1:33: error: definition of concept 'concept bool C()' has multiple statements
 template<typename> concept bool C() { return true; }
                                 ^
bug.cc: At global scope:
bug.cc:7:4: internal compiler error: in non_atomic_constraint_p, at cp/logic.cc:318
 A<B> a;
    ^
0x61694b non_atomic_constraint_p
	../../gcc/gcc/cp/logic.cc:318
0x8dc3d0 any_p<std::_List_iterator<tree_node*>, bool (*)(tree_node*)>
	../../gcc/gcc/cp/logic.cc:67
0x8dc3d0 any_non_atomic_constraints_p
	../../gcc/gcc/cp/logic.cc:327
0x8dc3d0 analyze_atom
	../../gcc/gcc/cp/logic.cc:359
0x8dc3d0 analyze_term
	../../gcc/gcc/cp/logic.cc:468
0x8dc3d0 check_term
	../../gcc/gcc/cp/logic.cc:495
0x8db5cf check_goal
	../../gcc/gcc/cp/logic.cc:511
0x8db5cf check_proof
	../../gcc/gcc/cp/logic.cc:537
0x8db5cf prove_implication
	../../gcc/gcc/cp/logic.cc:754
0x8dc189 prove_implication
	../../gcc/gcc/cp/logic.cc:731
0x8dc189 subsumes_constraints_nonnull
	../../gcc/gcc/cp/logic.cc:786
0x8dc189 subsumes(tree_node*, tree_node*)
	../../gcc/gcc/cp/logic.cc:803
0x97c336 is_compatible_template_arg
	../../gcc/gcc/cp/pt.c:7571
0x97c336 convert_template_argument
	../../gcc/gcc/cp/pt.c:7810
0x97a66b coerce_template_parms
	../../gcc/gcc/cp/pt.c:8324
0x9738b6 lookup_template_class_1
	../../gcc/gcc/cp/pt.c:8860
0x9738b6 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*, int, int)
	../../gcc/gcc/cp/pt.c:9209
0x9a35dd finish_template_type(tree_node*, tree_node*, int)
	../../gcc/gcc/cp/semantics.c:3183
0x921034 cp_parser_template_id
	../../gcc/gcc/cp/parser.c:15830
0x92113e cp_parser_class_name
	../../gcc/gcc/cp/parser.c:22350
Please submit a full bug report, [etc.]

Without "-O" or "-g" the code is accepted.
The regression was introduced between 2017-11-26 and 2017-12-18.
Comment 1 Marek Polacek 2018-02-26 18:02:47 UTC
Started with r255569.
Comment 2 Jason Merrill 2018-02-26 19:05:14 UTC
Author: jason
Date: Mon Feb 26 19:04:42 2018
New Revision: 258009

URL: https://gcc.gnu.org/viewcvs?rev=258009&root=gcc&view=rev
Log:
	PR c++/84551 - ICE with concepts and -g.

	* parser.c (add_debug_begin_stmt): Do nothing in a concept.

Added:
    trunk/gcc/testsuite/g++.dg/concepts/debug1.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
Comment 3 Jason Merrill 2018-02-26 19:09:33 UTC
Fixed.