Bug 82401 - [8 Regression] error: qsort comparator non-negative on sorted output: 1 in insert_late_enum_def_bindings on an invalid code
Summary: [8 Regression] error: qsort comparator non-negative on sorted output: 1 in in...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: 8.0
Assignee: Jakub Jelinek
URL:
Keywords: ice-checking, ice-on-invalid-code
Depends on:
Blocks: qsort_chk
  Show dependency treegraph
 
Reported: 2017-10-02 12:15 UTC by Martin Liška
Modified: 2017-11-22 23:24 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-11-22 00:00:00


Attachments
gcc8-pr82401.patch (637 bytes, patch)
2017-11-22 16:03 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2017-10-02 12:15:22 UTC
After Alexander's commit (r253295) I see:

$ cat ice.cpp
template <typename T> struct A
{
  enum E : T;
  void h ();
};
template <typename T> enum A<T>::E : T { e1, e2 };
template <> enum A<long long>::E : long long {};
template <typename T> struct C
{
  enum class E : T;
};
C<int>::E c3 = C<int>::E::e6;

$ g++-7 ice.cpp
ice.cpp:12:27: error: ‘e6’ is not a member of ‘C<int>::E’
 C<int>::E c3 = C<int>::E::e6;
                           ^~
$ g++-trunk ice.cpp
ice.cpp:7:47: error: qsort comparator non-negative on sorted output: 1
 template <> enum A<long long>::E : long long {};
                                               ^
ice.cpp:7:47: internal compiler error: qsort checking failed
0x5ee434 qsort_chk_error
	.././../gcc/vec.c:222
0x16207c5 qsort_chk(void*, unsigned long, unsigned long, int (*)(void const*, void const*))
	.././../gcc/vec.c:274
0x7287ef insert_late_enum_def_bindings(tree_node*, tree_node*)
	.././../gcc/cp/name-lookup.c:1727
0x6923d1 finish_enum_value_list(tree_node*)
	.././../gcc/cp/decl.c:14322
0x76058c cp_parser_enum_specifier
	.././../gcc/cp/parser.c:18222
0x76058c cp_parser_type_specifier
	.././../gcc/cp/parser.c:16644
0x76e156 cp_parser_decl_specifier_seq
	.././../gcc/cp/parser.c:13568
0x773355 cp_parser_single_declaration
	.././../gcc/cp/parser.c:26972
0x774467 cp_parser_explicit_specialization
	.././../gcc/cp/parser.c:16564
0x77a426 cp_parser_declaration
	.././../gcc/cp/parser.c:12669
0x77a6eb cp_parser_declaration_seq_opt
	.././../gcc/cp/parser.c:12599
0x77a9fa cp_parser_translation_unit
	.././../gcc/cp/parser.c:4390
0x77a9fa c_parse_file()
	.././../gcc/cp/parser.c:38907
0x8c0df6 c_common_parse_file()
	.././../gcc/c-family/c-opts.c:1113
Comment 1 Jakub Jelinek 2017-11-22 16:03:55 UTC
Created attachment 42683 [details]
gcc8-pr82401.patch

Untested fix.
Comment 2 Jakub Jelinek 2017-11-22 22:36:24 UTC
Author: jakub
Date: Wed Nov 22 22:35:52 2017
New Revision: 255084

URL: https://gcc.gnu.org/viewcvs?rev=255084&root=gcc&view=rev
Log:
	PR c++/82401
	* name-lookup.c (member_name_cmp): Return 0 if a == b.

	* g++.dg/cpp0x/pr82401.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/pr82401.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/name-lookup.c
    trunk/gcc/testsuite/ChangeLog
Comment 3 Jakub Jelinek 2017-11-22 23:24:18 UTC
Fixed.