Bug 67159 - [c++concepts] Segfault while diagnosing constraint violation
Summary: [c++concepts] Segfault while diagnosing constraint violation
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: c++-concepts
: P3 normal
Target Milestone: 6.0
Assignee: Jason Merrill
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-08 20:06 UTC by Casey Carter
Modified: 2015-08-09 11:23 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Preprocessed test case (101.04 KB, text/plain)
2015-08-08 20:06 UTC, Casey Carter
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Casey Carter 2015-08-08 20:06:54 UTC
Created attachment 36149 [details]
Preprocessed test case

r226725 crashes while diagnosing a constraint violation in this correct program (pre-processed test case attached):

#include <stl2/detail/iterator/concepts.hpp>

template <class T>
concept bool R = requires (T& t) {
  { t.begin() } -> stl2::Iterator;
  { t.end() } -> stl2::Sentinel<decltype(t.begin())>;
};

struct foo {
  int* begin();
  int* end();
};

R{T}
constexpr bool f() { return true; }

static_assert(f<foo>());

resulting in:

~/concept-gcc-r226725/bin/g++ -std=gnu++1z foo.i -c
foo.cpp:17:22: error: cannot call function ‘constexpr bool f() [with T = foo]’
 static_assert(f<foo>());
                      ^
foo.cpp:15:16: note:   constraints not satisfied
 constexpr bool f() { return true; }
                ^
‘
Segmentation fault
 static_assert(f<foo>());
                      ^
0xc9055f crash_signal
	../../gcc/toplev.c:352
0xf0f506 contains_struct_check(tree_node const*, tree_node_structure_enum, char const*, int, char const*)
	../../gcc/tree.h:3227
0xf0f506 int_cst_value(tree_node const*)
	../../gcc/tree.c:10982
0x6d03c4 get_non_default_template_args_count
	../../gcc/cp/error.c:202
0x6da0b1 dump_template_argument_list
	../../gcc/cp/error.c:211
0x6d52bd dump_decl
	../../gcc/cp/error.c:1215
0x6dae15 expr_to_string
	../../gcc/cp/error.c:2954
0x6dea54 cp_printer
	../../gcc/cp/error.c:3530
0x13a309a pp_format(pretty_printer*, text_info*)
	../../gcc/pretty-print.c:612
0x13a0573 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
	../../gcc/diagnostic.c:915
0x13a09d1 inform(unsigned int, char const*, ...)
	../../gcc/diagnostic.c:1044
0x738a81 cp_build_function_call_vec(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int)
	../../gcc/cp/typeck.c:3492
0x5f1e29 build_new_function_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool, int)
	../../gcc/cp/call.c:4090
0x77b850 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool, bool, int)
	../../gcc/cp/semantics.c:2391
0x6fa019 cp_parser_postfix_expression
	../../gcc/cp/parser.c:6419
0x6fe92a cp_parser_unary_expression
	../../gcc/cp/parser.c:7486
0x6ff53f cp_parser_binary_expression
	../../gcc/cp/parser.c:8223
0x6ffc9f cp_parser_assignment_expression
	../../gcc/cp/parser.c:8481
0x700115 cp_parser_constant_expression
	../../gcc/cp/parser.c:8727
0x702a94 cp_parser_static_assert
	../../gcc/cp/parser.c:12296
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Jason Merrill 2015-08-08 22:02:01 UTC
Author: jason
Date: Sat Aug  8 22:01:29 2015
New Revision: 226738

URL: https://gcc.gnu.org/viewcvs?rev=226738&root=gcc&view=rev
Log:
	PR c++/67159
	* constraint.cc (finish_template_introduction):
	SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT.

Added:
    trunk/gcc/testsuite/g++.dg/concepts/diagnostic1.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/constraint.cc
Comment 2 Jason Merrill 2015-08-08 22:12:52 UTC
Fixed.
Comment 3 Casey Carter 2015-08-08 22:15:41 UTC
Thanks once again, Jason. Procedural question: now that c++-concepts has landed on trunk, should I be tagging bug reports differently? i.e., Version=6.0 and maybe "[concepts]" in the title?
Comment 4 Jason Merrill 2015-08-09 11:23:03 UTC
(In reply to Casey Carter from comment #3)
> Thanks once again, Jason. Procedural question: now that c++-concepts has
> landed on trunk, should I be tagging bug reports differently? i.e.,
> Version=6.0 and maybe "[concepts]" in the title?

Sounds good.