[Bug c/94053] New: Segmentation fault in default Optimization, but works well in O1 ~ Os

2020-03-05 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94053

Bug ID: 94053
   Summary: Segmentation fault in default Optimization, but works
well in O1 ~ Os
   Product: gcc
   Version: 8.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

Hi, The code test.c

#include 
#include 

void foo(int* a ) {
a[-1]=1;
}
int main (int argc, char* argv[]) {
int size= 10;
printf("%d\n", size);
int array[size];
memset(array,0,size*sizeof(int));
foo(array);
return 0;
}

is getting "Segmentation fault" when I use `gcc test.c` to compile and 
`./a.out` 
 to execute it (in Ubuntu 16.04, gcc 8.1.0).

I know that the index of an array is -1 and not suitable, but when I add -O1,
-O2, -O3, or -Os to compile it, then the fault is gone.

[Bug c/94055] New: Segmentation fault in memet function

2020-03-05 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94055

Bug ID: 94055
   Summary: Segmentation fault in memet function
   Product: gcc
   Version: 8.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

Hi, this code test.c

#include 
#include 
#include 
int main (int argc, char* argv[]) {
int size = 1000;
printf("%d \n", size);
int array[size];
memset(array,0,size*sizeof(int));
return 0;
}

get "Segmentation fault" when I use a larger size, that is to say, smaller size
is ok (in ubuntu 16.04, gcc 8.1.0).

Surprisingly, when I use O1, O2, O3, or Os to compile, it works well.

[Bug c/94055] Segmentation fault in memet function

2020-03-05 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94055

--- Comment #3 from Haoxin Tu  ---
I see. Thank you for your responding.

Have a good day!

[Bug c/94322] New: Detected memory leaks while using clang AddressSanitizer to build GCC

2020-03-25 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94322

Bug ID: 94322
   Summary: Detected memory leaks while using clang
AddressSanitizer to build GCC
   Product: gcc
   Version: 8.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

Hi, I use clang with AddressSanitizer and detected memory leaks while building
GCC.

The SUMMARY are:

=
==7174==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 112 byte(s) in 1 object(s) allocated from:
#0 0x4debb0 
(/home/haoxin/corpus-compilers/clang-build-gcc8/build/gcc/build/genhooks+0x4debb0)
#1 0x521a45 
(/home/haoxin/corpus-compilers/clang-build-gcc8/build/gcc/build/genhooks+0x521a45)
#2 0x51e2a9 
(/home/haoxin/corpus-compilers/clang-build-gcc8/build/gcc/build/genhooks+0x51e2a9)
#3 0x51a8e5 
(/home/haoxin/corpus-compilers/clang-build-gcc8/build/gcc/build/genhooks+0x51a8e5)
#4 0x7f20623dc82f  (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

Direct leak of 23 byte(s) in 1 object(s) allocated from:
#0 0x4de998 
(/home/haoxin/corpus-compilers/clang-build-gcc8/build/gcc/build/genhooks+0x4de998)
#1 0x5219c1 
(/home/haoxin/corpus-compilers/clang-build-gcc8/build/gcc/build/genhooks+0x5219c1)
#2 0x521b7d 
(/home/haoxin/corpus-compilers/clang-build-gcc8/build/gcc/build/genhooks+0x521b7d)
#3 0x51bb89 
(/home/haoxin/corpus-compilers/clang-build-gcc8/build/gcc/build/genhooks+0x51bb89)
#4 0x7f20623dc82f  (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

Indirect leak of 13368 byte(s) in 456 object(s) allocated from:
#0 0x4de998 
(/home/haoxin/corpus-compilers/clang-build-gcc8/build/gcc/build/genhooks+0x4de998)
#1 0x5219c1 
(/home/haoxin/corpus-compilers/clang-build-gcc8/build/gcc/build/genhooks+0x5219c1)
#2 0x521b7d 
(/home/haoxin/corpus-compilers/clang-build-gcc8/build/gcc/build/genhooks+0x521b7d)
#3 0x51a9f0 
(/home/haoxin/corpus-compilers/clang-build-gcc8/build/gcc/build/genhooks+0x51a9f0)
#4 0x7f20623dc82f  (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

Indirect leak of 8168 byte(s) in 1 object(s) allocated from:
#0 0x4debb0 
(/home/haoxin/corpus-compilers/clang-build-gcc8/build/gcc/build/genhooks+0x4debb0)
#1 0x521a45 
(/home/haoxin/corpus-compilers/clang-build-gcc8/build/gcc/build/genhooks+0x521a45)
#2 0x520384 
(/home/haoxin/corpus-compilers/clang-build-gcc8/build/gcc/build/genhooks+0x520384)
#3 0x51f5af 
(/home/haoxin/corpus-compilers/clang-build-gcc8/build/gcc/build/genhooks+0x51f5af)
#4 0x51ab44 
(/home/haoxin/corpus-compilers/clang-build-gcc8/build/gcc/build/genhooks+0x51ab44)
#5 0x7f20623dc82f  (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

Indirect leak of 7296 byte(s) in 456 object(s) allocated from:
#0 0x4de998 
(/home/haoxin/corpus-compilers/clang-build-gcc8/build/gcc/build/genhooks+0x4de998)
#1 0x5219c1 
(/home/haoxin/corpus-compilers/clang-build-gcc8/build/gcc/build/genhooks+0x5219c1)
#2 0x51a9e5 
(/home/haoxin/corpus-compilers/clang-build-gcc8/build/gcc/build/genhooks+0x51a9e5)
#3 0x7f20623dc82f  (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

SUMMARY: AddressSanitizer: 28967 byte(s) leaked in 915 allocation(s).
Makefile:2504: recipe for target 's-tm-texi' failed
make[3]: *** [s-tm-texi] Error 1
make[3]: *** Waiting for unfinished jobs
31 warnings generated.
19 warnings generated.
rm fsf-funding.pod gcov.pod gpl.pod cpp.pod gcc.pod
make[3]: Leaving directory
'/home/haoxin/corpus-compilers/clang-build-gcc8/build/gcc'
Makefile:4617: recipe for target 'all-stage1-gcc' failed
make[2]: *** [all-stage1-gcc] Error 2
make[2]: Leaving directory
'/home/haoxin/corpus-compilers/clang-build-gcc8/build'
Makefile:24352: recipe for target 'stage1-bubble' failed
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory
'/home/haoxin/corpus-compilers/clang-build-gcc8/build'
Makefile:944: recipe for target 'all' failed


Here are my instructions:

$export FUZZ_FLAGS="-O2 -fno-omit-frame-pointer -g -fsanitize=address
-fsanitize-coverage=edge,trace-pc-guard,indirect-calls,trace-cmp,trace-div,trace-gep"

$CC="clang $FUZZ_FLAGS" CXX="clang++ $FUZZ_FLAGS" ../configure

$make -j4


Without FUZZ_FLAGS, clang can build GCC well.

I used GCC-8.1.0, clang-6.0, and Ubuntu16.04.

[Bug c/94686] New: internal compiler error: in gimplify_expr

2020-04-21 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94686

Bug ID: 94686
   Summary: internal compiler error: in gimplify_expr
   Product: gcc
   Version: 6.5.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

Hi, the test.c (reduced by C-Reduce)

#include 
int a = 0,b = 0;
int main(){
int c = (int)(long)(b * 0 >= a & b * 0 >= a);
return 0;
}

$gcc-6 test.c

then got the ICE error

test.c: In function ‘main’:
test.c:6:33: internal compiler error: in gimplify_expr, at gimplify.c:11192
  int c = (int)(long)(b * 0 >= a & b * 0 >= a);
 ^
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.


My GCC version is 

$gcc-6 --version

gcc-6 (Ubuntu 6.5.0-2ubuntu1~18.04) 6.5.0 20181026
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/91867] Internal compiler error in simple for(auto) loop when using -std=c++11 with -fconcepts

2020-05-22 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91867

Haoxin Tu  changed:

   What|Removed |Added

 CC||haoxintu at gmail dot com

--- Comment #4 from Haoxin Tu  ---
I also find this in a simple code.

test.cc
include
int main(){
 for(int i:{});
}

$g++ --version
g++ (GCC) 10.0.1 20200420 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$g++ -fconcepts -std=c++11 test.cc
test.cc: In function ‘int main()’:
test.cc:3:13: internal compiler error: in type_unification_real, at
cp/pt.c:21752
3 |  for(int i:{});
  | ^
0x6bf3ed type_unification_real
../../gcc/cp/pt.c:21752
0xa427ff do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int)
../../gcc/cp/pt.c:28954
0x9e4025 build_range_temp
../../gcc/cp/parser.c:12516
0x9ee792 cp_convert_range_for(tree_node*, tree_node*, tree_node*, tree_node*,
unsigned int, bool, unsigned short)
../../gcc/cp/parser.c:12616
0x9f40b0 cp_parser_range_for
../../gcc/cp/parser.c:12498
0xa1ea0a cp_parser_for
../../gcc/cp/parser.c:12354
0xa1ea0a cp_parser_iteration_statement
../../gcc/cp/parser.c:12902
0xa00ccd cp_parser_statement
../../gcc/cp/parser.c:11353
0xa022d8 cp_parser_statement_seq_opt
../../gcc/cp/parser.c:11835
0xa023b8 cp_parser_compound_statement
../../gcc/cp/parser.c:11785
0xa198b5 cp_parser_function_body
../../gcc/cp/parser.c:23060
0xa198b5 cp_parser_ctor_initializer_opt_and_function_body
../../gcc/cp/parser.c:23111
0xa1cbed cp_parser_function_definition_after_declarator
../../gcc/cp/parser.c:28993
0xa1dbd9 cp_parser_function_definition_from_specifiers_and_declarator
../../gcc/cp/parser.c:28909
0xa1dbd9 cp_parser_init_declarator
../../gcc/cp/parser.c:20667
0x9fe992 cp_parser_simple_declaration
../../gcc/cp/parser.c:13731
0xa27ba2 cp_parser_declaration
../../gcc/cp/parser.c:13430
0xa2832a cp_parser_translation_unit
../../gcc/cp/parser.c:4731
0xa2832a c_parse_file()
../../gcc/cp/parser.c:43972
0xb3d5eb c_common_parse_file()
../../gcc/c-family/c-opts.c:1190
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

[Bug c++/95326] New: UBsan can not detect signed-integer-overflow correctly

2020-05-25 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95326

Bug ID: 95326
   Summary: UBsan can not detect signed-integer-overflow correctly
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This case example.cpp

#include 

volatile wchar_t g_volatile_wchar = 2082494266;
volatile unsigned short g_volatile_ushort = 31503U;

int main () {
unsigned long l_var_ulong = 526562505494506029UL;
const wchar_t l_const_wchar = 1188246531;
g_volatile_ushort = l_var_ulong + l_const_wchar * g_volatile_wchar;
std::cout << "hello" << std::endl;
return 0;
}

can not detect signed-integer-overflow runtime error in gcc-trunk

$g++ -fsanitize=signed-integer-overflow example.cpp ; ./a.out
hello

But in clang-trunk
$clang++ -fsanitize=signed-integer-overflow test.cc ; ./a.out
example.cpp:9:53: runtime error: signed integer overflow: 1188246531 *
2082494266 cannot be represented in type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior example.cpp:9:53 in 
hello

godbolt clang-trunk : https://godbolt.org/z/s4-AqW
godbolt gcc-trunk : https://godbolt.org/z/k7NhG6

[Bug c++/95326] GCC can not detect signed-integer-overflow correctly

2020-05-25 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95326

Haoxin Tu  changed:

   What|Removed |Added

Version|11.0|10.0

--- Comment #1 from Haoxin Tu  ---
I also found another case example.cpp

#include 

unsigned short g_var_ushort = 52781U;
const unsigned int g_const_uint = 2331271054U;

int main () {
//test_function();
short l_var_short = -14674;
volatile unsigned char l_volatile_uchar = 151U;
long l_var_long = 572469544701421587L;

g_var_ushort = l_volatile_uchar - l_var_short % g_const_uint * l_var_long;
std::cout << "hello" << std::endl;
return 0;
}

$g++ -fsanitize=signed-integer-overflow example.cpp ; ./a.out
hello

$clang++ -fsanitize=signed-integer-overflow example.cpp ; ./a.out
example.cpp:12:66: runtime error: signed integer overflow: 1963681568 *
572469544701421587 cannot be represented in type 'long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior example.cpp:12:66 in 
hello

My g++ version is
$g++ --version
g++ (GCC) 10.0.1 20200420 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I have tested all GCC versions including GCC-8, GCC-9, GCC-10, and GCC-Trunk in
Godbolt, they can not detect this UB as well.

[Bug middle-end/95326] GCC can not detect signed-integer-overflow correctly

2020-05-26 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95326

--- Comment #3 from Haoxin Tu  ---
Would GCC shorten the multiple to be other types early as well? I also find
some cases in "short" type with the same symptom. I am still testing now and
don't know there are any cases in rest of types(such as char, int, long...)
have the problem.

By the way, should I file a new bug report when I found another type (for
example,int) that GCC can not detect the signed-integer-overflow UB issues?

[Bug c++/95334] New: GCC detect missing signed-integer-overflow when add "const"

2020-05-26 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95334

Bug ID: 95334
   Summary: GCC detect missing signed-integer-overflow when add
"const"
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code test1.cc

#include 
#include 

wchar_t g_wchar = 0;
int g_int = -1975564288;
int l_int = -1227761344;

int main () {
g_wchar = l_int + g_int;
std::cout << g_wchar << std::endl;
std::cout << "WCHAR_MIN = " << WCHAR_MIN << std::endl;
std::cout << "WCHAR_MAX = " << WCHAR_MAX << std::endl;
return 0;
}

GCC can detect UB correctly

$g++ -w -fsanitize=signed-integer-overflow ; ./a.out
test1.cc:9:21: runtime error: signed integer overflow: -1227761344 +
-1975564288 cannot be represented in type 'int'
1091641664
WCHAR_MIN = -2147483648
WCHAR_MAX = 2147483647

But in this case test2.cc add "const" for int
#include 
#include 

wchar_t g_wchar = 0;
const int g_int = -1975564288;
const int l_int = -1227761344;

int main () {
g_wchar = l_int + g_int;
std::cout << g_wchar << std::endl;
std::cout << "WCHAR_MIN = " << WCHAR_MIN << std::endl;
std::cout << "WCHAR_MAX = " << WCHAR_MAX << std::endl;
return 0;
}

GCC detect nothing.

$g++ -w -fsanitize=signed-integer-overflow test2.cc; ./a.out
1091641664
WCHAR_MIN = -2147483648
WCHAR_MAX = 2147483647

My g++ version

$g++ --version
g++ (GCC) 11.0.0 20200526 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I have tested them in recent GCC versions including GCC-8, GCC-9, GCC-10, they
have the same symptom as well.

I also test them in clang-trunk, above two testcases can be detected as "signed
integer overflow".

[Bug c++/95334] GCC detect missing signed-integer-overflow when add "const"

2020-05-26 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95334

--- Comment #2 from Haoxin Tu  ---
I also find these cases

test1.cc
#include 

bool g_bool = 0;
long g_long = -4075183478711827874L;
const long l_long = 7122990940771016367L;
int main () {
g_bool = g_long * l_long;
std::cout << g_bool << std::endl;
return 0;
}

GCC detects nothing.

$g++ -w -fsanitize=signed-integer-overflow test1.cc
1

But when remove "const"
test2.cc
#include 

bool g_bool = 0;
long g_long = -4075183478711827874L;
const long l_long = 7122990940771016367L;
int main () {
g_bool = g_long * l_long;
std::cout << g_bool << std::endl;
return 0;
}

GCC can dectect the signed-integer-overflow.

$g++ -w -fsanitize=signed-integer-overflow test2.cc
test2.cc:7:21: runtime error: signed integer overflow: -4075183478711827874 *
7122990940771016367 cannot be represented in type 'long int'
1

[Bug c++/95354] New: GCC misuse "nonnull-attribute" option and can not detect it as UB as well

2020-05-26 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95354

Bug ID: 95354
   Summary: GCC misuse "nonnull-attribute" option and can not
detect it as UB as well
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This case test.cc

#include
#include
void has_nonnull_argument(__attribute__((nonnull)) int *p) { 
 ; 
}
int main () {
has_nonnull_argument(NULL);
std::cout << "ok" << std::endl;
return 0;
}

in GCC-trunk

$./g++ -fsanitize=undefined test.cc ; ./a.out 
test.cc:3:57: warning: ‘nonnull’ attribute only applies to function types
[-Wattributes]
3 | void has_nonnull_argument(__attribute__((nonnull)) int *p) {
  | ^
ok

$./g++ -fsanitize=nonull-attribute test.cc ; ./a.out 
test.cc:3:57: warning: ‘nonnull’ attribute only applies to function types
[-Wattributes]
3 | void has_nonnull_argument(__attribute__((nonnull)) int *p) {
  | ^
ok

in Clang-trunk

$clang++ -fsanitize=nonnull-attribute test.cc ; ./a.out 
est.cc:7:30: warning: null passed to a callee that requires a non-null argument
[-Wnonnull]
has_nonnull_argument(NULL);
 ^
1 warning generated.
test.cc:7:26: runtime error: null pointer passed as argument 1, which is
declared to never be null
test.cc:3:42: note: nonnull attribute specified here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.cc:7:26 in 
ok

According to the description in
https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html#Instrumentation-Options
for "-fsanitize=nonull-attribute", it says "This option enables instrumentation
of calls, checking whether null values are not passed to arguments marked as
requiring a non-null value by the nonnull function attribute." 

I guess the warning message by GCC may also incorrect, the correct one should
look like in Clang produced.

I have tested them in recent GCC versions including GCC-8, GCC-9, and GCC-10,
they have the same symptom as well.

My GCC version is
$g++ --version
g++ (GCC) 11.0.0 20200526 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/95354] GCC misuse "nonnull-attribute" option and can not detect it as UB as well

2020-05-27 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95354

--- Comment #3 from Haoxin Tu  ---
I see. Are there any cases that can trigger the UB of nonnull-attribute? I
doubt the usage of “-fsanitize=nonnull-attribute” in GCC...

[Bug c++/95354] GCC misuse "nonnull-attribute" option and can not detect it as UB as well

2020-05-27 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95354

--- Comment #5 from Haoxin Tu  ---
(In reply to Jonathan Wakely from comment #4)
> (In reply to Haoxin Tu from comment #3)
> > I see. Are there any cases that can trigger the UB of nonnull-attribute? I
> > doubt the usage of “-fsanitize=nonnull-attribute” in GCC...
> 
> Yes, just use the attribute correctly.
> 
> Using:
> 
> __attribute__((nonnull)) void has_nonnull_argument(int *p) { 
>  ; 
> }
> 
> will cause UBsan to diagnose it:
> 
> nn.cc:7:25: runtime error: null pointer passed as argument 1, which is
> declared to never be null

Thanks, Jonathan, Got it ~

[Bug c++/95385] New: GCC stop detect UBs after a divide by zero in for statement

2020-05-28 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95385

Bug ID: 95385
   Summary: GCC stop detect UBs after a divide by zero in for
statement
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code test1.cc

#include
int main () {
int a = 1;
for (int i = 0; i < 10; ++i) {
a /= i; // Error: division by zero on the first iteration
}

int b = 0;
int bb = 0 / b;
0 / 0;
std::cout << "ok" << std::endl;
return 0;
}

$./g++ -w -fsanitize=integer-divide-by-zero test1.cc ; ./a.out 
test.cc:5:11: runtime error: division by zero
Floating point exception (core dumped)

GCC only detects one runtime error in for statement but leaves out detecting
the statements following ones.

In test2.cc

#include
int main () {
/*
int a = 1;
for (int i = 0; i < 10; ++i) {
a /= i; // Error: division by zero on the first iteration
}
*/

int b = 0;
int bb = 0 / b;
0 / 0;
std::cout << "ok" << std::endl;
return 0;
}
$./g++ -w -fsanitize=integer-divide-by-zero test2.cc ; ./a.out 
test.cc:11:16: runtime error: division by zero
test.cc:12:7: runtime error: division by zero
ok

Should the main function return from "return 0" rather than exit directly from
the for statement?

[Bug c++/95385] GCC stop detect UBs after a divide by zero in for statement

2020-05-29 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95385

--- Comment #3 from Haoxin Tu  ---
(In reply to Richard Biener from comment #2)
> We likely eliminate the dead 0/0 and 0/b instructions but fail for the one in
> the loop at -O0.  As soon as the actual instruction is carried out the
> program traps and obviously further runtime messages are no longer emitted.
> 
> There's no bug here.

Hi Richard, take look at this case 

test3.cc
#include
int main () {
for (int i = 0; i < 1; ++i) {
int a1 = 0;
int aa1 = a1/0; 
}
int b = 0;
int bb = 0 / b;
0 / 0;
std::cout << "ok" << std::endl;
return 0;
}

$./g++ -w -fsanitize=integer-divide-by-zero test3.cc ; ./a.out 
test3.cc:5:21: runtime error: division by zero

The actual instruction is carried out as you said.

But in test4.cc
#include
int main () {
for (int i = 0; i < 1; ++i) {
int b = 0;
int bb = 0 / b; 
0 / 0;
}
int b = 0;
int bb = 0 / b;
0 / 0;
std::cout << "ok" << std::endl;
return 0;
}

$$./g++ -w -fsanitize=integer-divide-by-zero test4.cc ; ./a.out 
test4.cc:5:20: runtime error: division by zero
test4.cc:6:11: runtime error: division by zero
test4.cc:9:16: runtime error: division by zero
test4.cc:10:7: runtime error: division by zero
ok

I am wondering why GCC treats test3.cc and test4.cc differently. Is there
something I didn’t understand correctly?

[Bug sanitizer/95430] New: [UBSAN] doesn't detect out of bounds in a simple case

2020-05-29 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95430

Bug ID: 95430
   Summary: [UBSAN] doesn't detect out of bounds in a simple case
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: sanitizer
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at 
gcc dot gnu.org
  Target Milestone: ---

This case test.cc

#include

int main () {
int a[10];
int *p1 = a - 100; // UB
int *p2 = a + 100; // UB
std::cout << "ok" << std::endl;
return 0;
}

$g++ -fsanitize=undefined test.cc ; ./a.out
ok

While in Clang

$clang++ -fsanitize=undefined test.cc ; ./a.out
test.cc:5:17: runtime error: index -100 out of bounds for type 'int [10]'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.cc:5:17 in 
test.cc:6:17: runtime error: index 100 out of bounds for type 'int [10]'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.cc:6:17 in 
ok

My GCC version is

$g++ --version
g++ (GCC) 11.0.0 20200526 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

GCC doesn't trigger warning or runtime error in out of bounds in an array.

[Bug c++/95461] New: GCC misses -Warray-bounds warning message

2020-06-01 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95461

Bug ID: 95461
   Summary: GCC misses -Warray-bounds warning message
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This case test.cc

#include
int main () {
int a[10] = {0};
a[11] = 0;
std::cout << "ok" << std::endl;
return 0;
}

produce nothing in gcc-trunk.


While in clang

$clang++ test.cc
test.cc:4:5: warning: array index 11 is past the end of the array (which
contains 10 elements) [-Warray-bounds]
a[11] = 0;
^ ~~
test.cc:3:5: note: array 'a' declared here
int a[10] = {0};
^
1 warning generated.


My gcc version is 
g++ (GCC) 11.0.0 20200526 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

All GCC versions have this missing.

[Bug sanitizer/95385] GCC stop detect UBs after a divide by zero in for statement

2020-06-01 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95385

--- Comment #4 from Haoxin Tu  ---
(In reply to Haoxin Tu from comment #3)

Hi, so sorry to bother you.

Is still there any problem here? Please take a look at test3.cc and test4.cc.
Thank you so much.

[Bug c++/95473] New: GCC misses -Wnull-dereference warning in a simple code

2020-06-01 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95473

Bug ID: 95473
   Summary: GCC misses -Wnull-dereference warning in a simple code
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

$cat null_ref.cc
int main(){
int &x1 = *(int *)nullptr; // null reference
return 0;
}

GCC can not catch any warning when I use -Wnull-dereference option. 
I also try to add -O1~Os, but GCC still produces nothing.

While in clang

$clang++-trunk -Wnull-dereference null_ref.cc 
null_ref.cc:2:15: warning: binding dereferenced null pointer to reference has
undefined behavior [-Wnull-dereference]
int &x1 = *(int *)nullptr; // null reference
  ^~~
1 warning generated.

$g++ --version
g++ (GCC) 11.0.0 20200526 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/95475] New: Imprecise column number of runtime error in unreachable program point

2020-06-02 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95475

Bug ID: 95475
   Summary: Imprecise column number of runtime error in
unreachable program point
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

$cat test.cc
int main(){
int var = 2;
switch (var) {
case 1:  
default:   
__builtin_unreachable();
}
}

$cat test.c
int main(){
int var = 2;
switch (var) {
case 1:  
default:   
__builtin_unreachable();

}
}

$g++ -fsanitize=undefined test.cc ; ./a.out
test.cc:6:34: runtime error: execution reached an unreachable program point

$gcc -fsanitize=undefined test.c ; ./a.out
test.c:6:13: runtime error: execution reached an unreachable program point

In clang-trunk

$clang++ -fsanitize=undefined test.cc ; ./a.out
test.cc:6:13: runtime error: execution reached an unreachable program point
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.cc:6:13 in 

$clang -fsanitize=undefined test.c ; ./a.out
test.c:6:13: runtime error: execution reached an unreachable program point
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.c:6:13 in 

$g++ --version
g++ (GCC) 11.0.0 20200526 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/95475] Imprecise column number of runtime error in unreachable program point

2020-06-02 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95475

--- Comment #2 from Haoxin Tu  ---
(In reply to Andrew Pinski from comment #1)
> The question is where should it be, at the open of the () or the start of
> the identifier __builtin_unreachable ?  In C++, it is the open.  In C, it is
> the start.

Hi, Andrew,

My question is that GCC treats the identifier "__builtin_unreachable" and
normal identifier differently?

For example

$cat test.cc
int foo_long_identifier(){;}
int main(){
   foo_long_identifier();   
}

$g++ -w -fsanitize=undefined test.cc ; ./a.out
test.cc:1:5: runtime error: execution reached the end of a value-returning
function without returning a value

I think this time the column number is the start of the identifier
"foo_long_identifier" rather than "()".

[Bug c++/65969] typename allowed in using declaration of non-types names

2020-06-05 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65969

Haoxin Tu  changed:

   What|Removed |Added

 CC||haoxintu at gmail dot com

--- Comment #3 from Haoxin Tu  ---
This case also reproduces the issue

namespace g_namespace {
int var = 1;
}
int main() {
  using typename g_namespace::var; //should be compiled failed but succeeded
  return 0;
}

[Bug c++/95559] New: Compiling "{{}}" result is inconsistent in different versions

2020-06-05 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95559

Bug ID: 95559
   Summary: Compiling "{{}}" result is inconsistent in different
versions
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This case test.cc

#include
int main() {
return {{}};
}

In the version of GCC 6.1 - 8.4, it's compiled ok.

But in GCC 6.1 lower and 8.4 higher version, for example, in GCC trunk

$g++-trunk test.cc 
test.cc: In function 'int main()':
test.cc:3:15: error: too many braces around scalar initializer for type 'int'
3 | int var = {{}};
  | 

I also compiled test.cc in recent released Clang, and they all accept "{{}}".

Should GCC compile "{{}}" fine also? I think this is a supported feature
according to https://en.cppreference.com/w/cpp/language/return.

[Bug c++/95564] New: GCC rejects lambda expression with "noexcept(1+1)"

2020-06-06 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95564

Bug ID: 95564
   Summary: GCC rejects lambda expression with "noexcept(1+1)"
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code test.cc

int main(){
auto a = [ & ] (...) noexcept(1+1) {};
return 0;
}

$g++-trunk test.cc
test.cc:2:38: error: narrowing conversion of '2' from 'int' to 'bool'
[-Wnarrowing]
2 | auto a = [ & ] (...) noexcept(1+1) {};
  |  

GCC fails to compile it, while clang, icc, or msvc accept it.

[Bug c++/95597] New: Rejects using-declaration with "typename" in global area

2020-06-08 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95597

Bug ID: 95597
   Summary: Rejects using-declaration with "typename" in global
area
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This case test.cc

typedef int T;
using typename ::T;

GCC fails to compile it.

$g++ -c test.cc
test.cc:2:18: error: expected nested-name-specifier before 'T'
2 | using typename ::T;
  |  ^

I guess that GCC might have something wrong in dealing with global "::" with
"typename"(the code "int a; using ::a;" is compiled ok), and this case is not
the same as bug 14258 or bug 3303. 

I also test this case in clang, icc, and msvc, they all accept test.cc.

[Bug c++/95610] New: GCC fails to get global variable via "::" in class specifier

2020-06-09 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95610

Bug ID: 95610
   Summary: GCC fails to get global variable via "::" in class
specifier
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This case test.cc

class s;
class ::s { } ss;

$g++ -c test.cc
test.cc:2:11: error: global qualification of class name is invalid before ‘{’
token
2 | class ::s {int a;} ss;
  | 

GCC fails to compile this c++ code, replacing "class" with "struct" or "union"
also reproduces above result.

Also, if test.cc removes "::", GCC compiles it well. 

I also tested test.cc in clang, icc, or msvc, and they compile it successfully.

[Bug c++/95559] GCC fails to compile "{{}}" in some versions

2020-06-09 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95559

--- Comment #2 from Haoxin Tu  ---
(In reply to Marek Polacek from comment #1)
> I can't find a version of GCC that compiled this.  

Hi, so sorry I might use the wrong test case. Please try this case bug.cc
instead

#include 
int main(){
int a = {{}};
std::cout << a << std::endl;
return 0;
}

In godbolt https://godbolt.org/z/K_drKC .

Also, in my machine,

$g++-8 test.cc ; ./a.out
0

$g++-8 --version
g++-8 (Ubuntu 8.4.0-1ubuntu1~18.04) 8.4.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$g++-trunk bug.cc
bug.cc: In function ‘int main()’:
bug.cc:3:16: error: too many braces around scalar initializer for type ‘int’
3 | int a = {{}};
  |  

$g++-trunk --version
g++ (GCC) 11.0.0 20200526 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

> I don't think this is rejects-valid.

I guess clang might have some issue in compiling "{{}}", clang accepts this
code but icc or msvc reject.

Please take a look at above situation, thanks ~

[Bug c++/95559] GCC fails to compile "{{}}" in some versions

2020-06-09 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95559

--- Comment #3 from Haoxin Tu  ---
(In reply to Haoxin Tu from comment #2)
> $g++-8 test.cc ; ./a.out
> 0

Here is 

> $g++-8 bug.cc ; ./a.out
> 0

[Bug c++/95559] GCC accepts "too many braces around scalar initializer " in the version of 6.1 - 8.4

2020-06-10 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95559

--- Comment #5 from Haoxin Tu  ---
(In reply to Marek Polacek from comment #4)
> That's the same case, initializing an int with {{}}.  GCC 8 compiled the
> second testcase, but that was fixed in r269045.

Ok, got it. At least this was a bug, can you change the status to DUPLICATE if
you are convenience? Thank you so much~

[Bug c++/95641] New: Bogus error message in the class base specifier

2020-06-11 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95641

Bug ID: 95641
   Summary: Bogus error message in the class base specifier
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code bug.cc

class A {};
class B : virtual class A{};

In gcc-trunk

$g++ -c bug.cc
bug.cc:2:19: error: expected class-name before ‘class’
2 | class B : virtual class A{};
  |   ^
bug.cc:2:19: error: expected ‘{’ before ‘class’
bug.cc:2:25: error: redefinition of ‘class A’
2 | class B : virtual class A{};
  | ^
bug.cc:1:7: note: previous definition of ‘class A’
1 | class A {};
  |   ^
bug.cc:2:1: error: multiple types in one declaration
2 | class B : virtual class A{};
  | ^

There are four error messages, I guess some of them are bogus.

I tested bug.cc in other compilers, and they only give one message.

In clang : "error: expected class name",
In icc : "error: expected an identifier",
In msvc : " error C2518: keyword 'class' is invalid in a base class list;
expected a class name".

Reproduced in Godbolt : https://godbolt.org/z/KuEPNF

[Bug c++/95656] New: Inconsistent output in compiling an undefined function

2020-06-12 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95656

Bug ID: 95656
   Summary: Inconsistent output in compiling an undefined function
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code bug.cc

#include
int main(){
int a ();
std::cout << a << std::endl;
return 0;
}

In GCC-trunk without "-fsanitize=undefined"

$g++ bug.cc ; ./a.out
1

$g++-trunk -fsanitize=undefined bug.cc
/tmp/ccm15L4R.o: In function `main':
bug.cc:(.text+0x8f): undefined reference to `a()'
collect2: error: ld returned 1 exit status

While in GCC-5

$g++-5 bug.cc ; ./a.out
1
$g++-5 -fsanitize=undefined bug.cc ; ./a.out
1

My GCC versions are

$g++-trunk --version
g++ (GCC) 11.0.0 20200526 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$g++-5 --version
g++-5 (Ubuntu 5.5.0-12ubuntu6~18.04) 5.5.0 20171010
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I also tested bug.cc in clang, it compiles well and output "1" whether adding
"-fsanitize=undefined" or not.

[Bug c++/95657] New: Bogus error message in "auto" with -std=c++11

2020-06-12 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95657

Bug ID: 95657
   Summary: Bogus error message in "auto" with -std=c++11
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code bug.cc

decltype (auto) foo( decltype (auto) a ){   }

in GCC-trunk

$g++ -c -std=c++11 bug.cc
bug.cc:1:11: error: expected primary-expression before ‘auto’
1 | decltype (auto) foo( decltype  (auto) a ){   }
  |   ^~~~
bug.cc:1:33: error: use of ‘auto’ in parameter declaration only available with
‘-std=c++14’ or ‘-std=gnu++14’
1 | decltype (auto) foo( decltype  (auto) a ){   }
  | ^~~~
bug.cc:1:33: error: use of ‘auto’ in parameter declaration only available with
‘-std=c++14’ or ‘-std=gnu++14’
bug.cc:1:33: error: use of ‘auto’ in parameter declaration only available with
‘-std=c++14’ or ‘-std=gnu++14’
bug.cc:1:33: error: use of ‘auto’ in parameter declaration only available with
‘-std=c++14’ or ‘-std=gnu++14’
bug.cc:1:33: error: use of ‘auto’ in parameter declaration only available with
‘-std=c++14’ or ‘-std=gnu++14’
bug.cc:1:33: error: use of ‘auto’ in parameter declaration only available with
‘-std=c++14’ or ‘-std=gnu++14’
bug.cc:1:33: error: expected primary-expression before ‘auto’
bug.cc:1:22: error: expected primary-expression before ‘decltype’
1 | decltype (auto) foo( decltype  (auto) a ){   }
  |  ^~~~

I am sure there were some duplicate error messages about "error: use of ‘auto’
in parameter declaration only available with ‘-std=c++14’ or ‘-std=gnu++14’".

While in clang

$clang++ -c -std=c++11 bug.cc
bug.cc:1:11: warning: 'decltype(auto)' type specifier is a C++14 extension
[-Wc++14-extensions]
decltype (auto) foo( decltype  (auto) a ){   }
  ^
bug.cc:1:33: warning: 'decltype(auto)' type specifier is a C++14 extension
[-Wc++14-extensions]
decltype (auto) foo( decltype  (auto) a ){   }
^
bug.cc:1:22: error: 'decltype(auto)' not allowed in function prototype
decltype (auto) foo( decltype  (auto) a ){   }
 ^~~~
bug.cc:1:1: error: deduced return types are a C++14 extension
decltype (auto) foo( decltype  (auto) a ){   }
^
2 warnings and 2 errors generated.

[Bug c++/95658] New: Bogus duplicate error message in "decltype(auto)" type specifier

2020-06-12 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95658

Bug ID: 95658
   Summary: Bogus duplicate error message in "decltype(auto)" type
specifier
   Product: gcc
   Version: 9.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code bug.cc in GCC 8.1 - 9.3 gives the bogus duplicate error messages.

$cat bug.cc
decltype (auto) var = 0;

Take GCC-9, GCC-10, GCC-trunk for example,

$g++-9 -c -std=c++11 bug.cc
bug.cc:1:11: error: expected primary-expression before ‘auto’
1 | decltype (auto) var = 0;
  |   ^~~~
bug.cc:1:11: error: expected ‘)’ before ‘auto’
1 | decltype (auto) var = 0;
  |  ~^~~~
  |   )
bug.cc:1:11: error: expected primary-expression before ‘auto’
1 | decltype (auto) var = 0;
  |   ^~~~
bug.cc:1:11: error: expected primary-expression before ‘auto’
bug.cc:1:11: error: expected primary-expression before ‘auto’
bug.cc:1:11: error: expected primary-expression before ‘auto’
bug.cc:1:1: error: expected unqualified-id before ‘decltype’
1 | decltype (auto) var = 0;
  | ^~~~

$g++-10 -c -std=c++11 bug.cc
bug.cc:1:11: error: expected primary-expression before ‘auto’
1 | decltype (auto) var = 0;
  |   ^~~~

$g++-trunk -c -std=c++11 bug.cc
bug.cc:1:11: error: expected primary-expression before ‘auto’
1 | decltype (auto) var = 0;
  |   ^~~~

GCC versions I used are

$g++-9 --version
g++-9 (Ubuntu 9.3.0-11ubuntu0~18.04.1) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$g++-10 --version
g++-10 (Ubuntu 10.1.0-2ubuntu1~18.04) 10.1.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$g++-trunk --version
g++ (GCC) 11.0.0 20200526 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/95659] New: Inconsistent error message in "default argument missing for parameter"

2020-06-12 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95659

Bug ID: 95659
   Summary: Inconsistent error message in "default argument
missing for parameter"
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

$cat bug.cc
int a;
long  foo1 ( void  = a, double  param2 ,decltype (auto) param3 = a){ }
long  foo2 ( void  = a, double  param2){ }

In gcc-trunk
$g++-trunk -w -c -std=c++14 bug.cc 
bug.cc:2:41: error: cannot declare a parameter with ‘decltype(auto)’
2 | long  foo1 ( void  = a, double  param2 ,decltype (auto) param3 = a){ }
  | ^~~
bug.cc:2:14: error: invalid use of type ‘void’ in parameter declaration
2 | long  foo1 ( void  = a, double  param2 ,decltype (auto) param3 = a){ }
  |  ^
bug.cc:3:14: error: invalid use of type ‘void’ in parameter declaration
3 | long  foo2 ( void  = a, double  param2){ }
  |  ^
bug.cc:3:33: error: default argument missing for parameter 2 of ‘long int
foo2(, double)’
3 | long  foo2 ( void  = a, double  param2){ }
  | ^~
bug.cc:3:14: note: ...following parameter 1 which has a default argument
3 | long  foo2 ( void  = a, double  param2){ }
  |  ^

GCC-trunk misses the "default argument missing for parameter" error message in
function "foo1()" but gives the message in function "foo2()".

In other GCC versions, they have consitent results, for example in GCC-10
$g++-10 -w -c -std=c++14 bug.cc 
bug.cc:2:41: error: cannot declare a parameter with ‘decltype(auto)’
2 | long  foo1 ( void  = a, double  param2 ,decltype (auto) param3 = a){ }
  | ^~~
bug.cc:2:14: error: invalid use of type ‘void’ in parameter declaration
2 | long  foo1 ( void  = a, double  param2 ,decltype (auto) param3 = a){ }
  |  ^
bug.cc:2:33: error: default argument missing for parameter 2 of ‘long int
foo1(, double)’
2 | long  foo1 ( void  = a, double  param2 ,decltype (auto) param3 = a){ }
  | ^~
bug.cc:2:14: note: ...following parameter 1 which has a default argument
2 | long  foo1 ( void  = a, double  param2 ,decltype (auto) param3 = a){ }
  |  ^
bug.cc:3:14: error: invalid use of type ‘void’ in parameter declaration
3 | long  foo2 ( void  = a, double  param2){ }
  |  ^
bug.cc:3:33: error: default argument missing for parameter 2 of ‘long int
foo2(, double)’
3 | long  foo2 ( void  = a, double  param2){ }
  | ^~
bug.cc:3:14: note: ...following parameter 1 which has a default argument
3 | long  foo2 ( void  = a, double  param2){ }
  |  ^

[Bug c++/95672] New: ICE in cxx_incomplete_type_diagnostic, at cp/typeck2.c:584

2020-06-14 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95672

Bug ID: 95672
   Summary: ICE in cxx_incomplete_type_diagnostic, at
cp/typeck2.c:584
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

$cat bug.cc
struct g_class : decltype  (auto) ... {  } ;

$g++ bug.cc
bug.cc:1:35: internal compiler error: in cxx_incomplete_type_diagnostic, at
cp/typeck2.c:584
1 | struct g_class : decltype  (auto) ... {  } ;
  |   ^~~
0x5cef74 cxx_incomplete_type_diagnostic(unsigned int, tree_node const*,
tree_node const*, diagnostic_t)
../../gcc/cp/typeck2.c:584
0x77b9af cxx_incomplete_type_diagnostic(tree_node const*, tree_node const*,
diagnostic_t)
../../gcc/cp/cp-tree.h:7705
0x77b9af complete_type_or_maybe_complain(tree_node*, tree_node*, int)
../../gcc/cp/typeck.c:156
0x77b9af complete_type_or_else(tree_node*, tree_node*)
../../gcc/cp/typeck.c:166
0x685881 xref_basetypes(tree_node*, tree_node*)
../../gcc/cp/decl.c:15099
0x6edfe9 cp_parser_class_head
../../gcc/cp/parser.c:24717
0x6edfe9 cp_parser_class_specifier_1
../../gcc/cp/parser.c:23874
0x6ee273 cp_parser_class_specifier
../../gcc/cp/parser.c:24248
0x6ee273 cp_parser_type_specifier
../../gcc/cp/parser.c:17762
0x6ef092 cp_parser_decl_specifier_seq
../../gcc/cp/parser.c:14410
0x6efbb1 cp_parser_simple_declaration
../../gcc/cp/parser.c:13664
0x7159c6 cp_parser_declaration
../../gcc/cp/parser.c:13484
0x7160b4 cp_parser_translation_unit
../../gcc/cp/parser.c:4761
0x7160b4 c_parse_file()
../../gcc/cp/parser.c:44034
0x7de74b c_common_parse_file()
../../gcc/c-family/c-opts.c:1190
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

$g++ --version
g++ (GCC) 11.0.0 20200605 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/95672] ICE in cxx_incomplete_type_diagnostic, at cp/typeck2.c:584

2020-06-14 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95672

--- Comment #1 from Haoxin Tu  ---
Noted that from GCC 6.1 to the trunk versions have this ICE, too.

[Bug c++/95672] ICE in cxx_incomplete_type_diagnostic, at cp/typeck2.c:584

2020-06-15 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95672

--- Comment #3 from Haoxin Tu  ---
(In reply to Martin Liška from comment #2)
> Is it an invalid code right?

Yes. I think it's not a valid code and other compilers do not accept it, too.

[Bug c++/95723] New: GCC get confused while parsing a code

2020-06-17 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95723

Bug ID: 95723
   Summary: GCC get confused while parsing a code
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code test.cc, GCC might get confused in parsing.

$cat test.cc
template  friend foo ( decltype (b=c

$g++-trunk -w test.cc
test.cc:1:12: error: ‘a’ has not been declared
1 | template  friend foo( decltype (b=c
  |^
test.cc:1:14: error: ‘friend’ used outside of class
1 | template  friend foo( decltype (b=c
  |  ^~
  |  --
test.cc:1:36: error: ‘b’ was not declared in this scope
1 | template  friend foo( decltype (b=c
  |^
test.cc:1:36: error: ‘b’ was not declared in this scope
test.cc:1:38: error: ‘c’ was not declared in this scope
1 | template  friend foo( decltype (b=c
  |  ^
test.cc:2: error: expected ‘,’ or ‘...’ at end of input
test.cc:1:39: error: expected ‘)’ at end of input
1 | template  friend foo( decltype (b=c
  |~  ^
  |   )
test.cc:2: error: expected initializer at end of input


$g++-10 -w test.cc
test.cc:1:12: error: ‘a’ has not been declared
1 | template  friend foo( decltype (b=c
  |^
test.cc:1:14: error: ‘friend’ used outside of class
1 | template  friend foo( decltype (b=c
  |  ^~
  |  --
test.cc:1:36: error: ‘b’ was not declared in this scope
1 | template  friend foo( decltype (b=c
  |^
test.cc:1:36: error: ‘b’ was not declared in this scope
test.cc:1:38: error: ‘c’ was not declared in this scope
1 | template  friend foo( decltype (b=c
  |  ^
test.cc:1:36: error: ‘b’ was not declared in this scope
1 | template  friend foo( decltype (b=c
  |^
test.cc:1:36: error: ‘b’ was not declared in this scope
test.cc:1:38: error: ‘c’ was not declared in this scope
1 | template  friend foo( decltype (b=c
  |  ^
test.cc:1:36: error: ‘b’ was not declared in this scope
1 | template  friend foo( decltype (b=c
  |^
test.cc:1:36: error: ‘b’ was not declared in this scope
test.cc:1:38: error: ‘c’ was not declared in this scope
1 | template  friend foo( decltype (b=c
  |  ^
test.cc:1:21: error: ISO C++ forbids declaration of ‘foo’ with no type
[-fpermissive]
1 | template  friend foo( decltype (b=c
  | ^~~
test.cc:1:36: error: ‘b’ was not declared in this scope
1 | template  friend foo( decltype (b=c
  |^
test.cc:1:36: error: ‘b’ was not declared in this scope
test.cc:1:38: error: ‘c’ was not declared in this scope
1 | template  friend foo( decltype (b=c
  |  ^
test.cc:1:39: error: expected ‘)’ at end of input
1 | template  friend foo( decltype (b=c
  |   ~  ~^
  |   )
test.cc:1:26: error: expected primary-expression before ‘decltype’
1 | template  friend foo( decltype (b=c
  |  ^
test.cc:1:39: error: expected ‘;’ at end of input
1 | template  friend foo( decltype (b=c
  |  ~^
  |   ;

I am sure that some error messages in GCC-10 are duplicated. I am also
wondering why GCC-trunk emits "error: expected initializer at end of input",
that's so confusing.

[Bug c++/95724] New: bogue error : "expected '{' before ')' token"

2020-06-17 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95724

Bug ID: 95724
   Summary: bogue error : "expected '{' before ')' token"
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
      Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code test.cc, GCC-trunk get a bogus error message and then get confused
with following code parsing.

$cat test.cc
template <(union : decltype(a = 0)>)


$g++-trunk -w -c test.cc
test.cc:1:11: error: expected identifier before ‘(’ token
1 | template <(union : decltype(a = 0)>)
  |   ^
test.cc:1:29: error: ‘a’ was not declared in this scope
1 | template <(union : decltype(a = 0)>)
  | ^
test.cc:1:29: error: ‘a’ was not declared in this scope
test.cc:1:34: error: expected ‘{’ before ‘)’ token
1 | template <(union : decltype(a = 0)>)
  |  ^
test.cc:1:36: error: expected unqualified-id before ‘)’ token
1 | template <(union : decltype(a = 0)>)
  |^

$g++-10 -w -c test.cc
test.cc:1:11: error: expected identifier before ‘(’ token
1 | template <(union : decltype(a = 0)>)
  |   ^
test.cc:1:29: error: ‘a’ was not declared in this scope
1 | template <(union : decltype(a = 0)>)
  | ^
test.cc:1:29: error: ‘a’ was not declared in this scope
test.cc:1:35: error: expected ‘{’ before ‘>’ token
1 | template <(union : decltype(a = 0)>)
  |   ^
test.cc:1:35: error: expected ‘,’ or ‘...’ before ‘>’ token
test.cc:1:36: error: expected ‘>’ at end of input
1 | template <(union : decltype(a = 0)>)
  |^
test.cc:1:36: error: expected unqualified-id at end of input

I guess GCC-trunk emits the bogus error message "expected ‘{’ before ‘)’
token", and the following error messages are inconsistent with GCC-10. So,
GCC-trunk might have something wrong with while parsing this code.

[Bug c++/95725] New: Confusing error diagnostic in an invalid template

2020-06-17 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95725

Bug ID: 95725
   Summary: Confusing error diagnostic in an invalid template
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code test.cc, makes GCC get confused while parsing.

$cat test.cc
template ’ before ‘;’ token
test.cc:1:22: error: expected unqualified-id before ‘;’ token


$g++-10 -w -c test.cc
test.cc:1:20: error: expected primary-expression before ‘=’ token
1 | template ’ before ‘;’ token
1 | template ’ before ‘decltype’
1 | template 

[Bug c++/95725] Confusing error diagnostic in an invalid template

2020-06-17 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95725

--- Comment #2 from Haoxin Tu  ---
(In reply to Martin Liška from comment #1)
> For the next time, can you please add 'ice-on-invalid-code' keyword?

Ok, so sorry it's my fault. But this is a diagnostic issue I think? I will add
"diagnostic" keywords next time.

[Bug c++/95724] bogue error : "expected '{' before ')' token"

2020-06-17 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95724

--- Comment #2 from Haoxin Tu  ---
(In reply to Martin Liška from comment #1)
> For the next time, can you please add 'ice-on-invalid-code' keyword?

I got it. So sorry for my mistake!

[Bug c++/95725] Confusing error diagnostic in an invalid template

2020-06-17 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95725

--- Comment #6 from Haoxin Tu  ---
Hi, there.

I hold the view that the compiler should have good fault tolerance, which means
giving an input(even invalid), the compiler might emit appropriate error
message diagnostics so that we can fix them into valid code according to the
diagnostics. 

I have tested in both GCC and Clang, the results show that GCC has lots of
unrelated diagnostic messages than Clang. 

In this report, GCC-trunk seems ok, but GCC-9 emits too many duplicated error
messages. So I guess there might something not correct in FE.

Finally, I am wondering if those cases are useful for the GCC community? If
not, I will stop reporting similar test cases (invalid code but let GCC get
confused while parsing it).

Thank you all!

[Bug c++/95725] Confusing error diagnostic in an invalid template

2020-06-17 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95725

--- Comment #7 from Haoxin Tu  ---
By the way, can you take a look at bug 95597 and bug 95659? I think GCC should
accept the first case and shouldn't miss the error message in the second code. 
Those cases are different from this report.

[Bug c++/95742] New: Bad error message in parsing a function with "decltype()"

2020-06-18 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95742

Bug ID: 95742
   Summary: Bad error message in parsing a function with
"decltype()"
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: diagnostic
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
CC: redi at gcc dot gnu.org
  Target Milestone: ---

This code test.cc, I think it's not a garbage input for GCC, but it parses
badly and emits some confusing error messages.

$cat test.cc

int foo( decltype(),int) { } 

$g++-trunk -c -w test.cc
test.cc:1:19: error: expected primary-expression before ‘)’ token
1 | int foo( decltype(),int)  { }
  |   ^
test.cc:1:10: error: expected primary-expression before ‘decltype’
1 | int foo( decltype(),int)  { }
  |  ^~
test.cc:1:21: error: expected primary-expression before ‘int’
1 | int foo( decltype(),int)  { }
  | ^~~
test.cc:1:24: error: expression list treated as compound expression in
initializer [-fpermissive]
1 | int foo( decltype(),int)  { }
  |^

While in Clang
$clang++ -c -w test.cc
test.cc:1:19: error: expected expression
int foo( decltype(),int)  { } 
  ^
1 error generated.


When I change the code into test1.cc, GCC get following results:

$cat test1.cc
void foo( decltype(),int) { } 

$g++-trunk -c -w test1.cc
test1.cc:1:6: error: variable or field ‘foo’ declared void
1 | void foo( decltype(),int)  { }
  |  ^~~
test1.cc:1:20: error: expected primary-expression before ‘)’ token
1 | void foo( decltype(),int)  { }
  |^
test1.cc:1:11: error: expected primary-expression before ‘decltype’
1 | void foo( decltype(),int)  { }
  |   ^~
test1.cc:1:22: error: expected primary-expression before ‘int’
1 | void foo( decltype(),int)  { }

This time GCC emits "error: variable or field ‘foo’ declared void"?

Also in Clang

$clang++ -c -w test1.cc
test1.cc:1:20: error: expected expression
void foo( decltype(),int)  { } 
   ^
1 error generated.

I guess GCC might can not recognize the function definition correctly?

[Bug c++/95744] New: Duplicate error message in a simple decltype specifier

2020-06-18 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95744

Bug ID: 95744
   Summary: Duplicate error message in a simple decltype specifier
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: diagnostic
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
CC: mpolacek at gcc dot gnu.org, redi at gcc dot gnu.org
  Target Milestone: ---

The test.cc includes a very simple valid decltype specifier with an undeclared
variable(I am definitely sure), but GCC emits two duplicated error messages on
it.

$cat test.cc
decltype(var) i = 100;

$g++-trunk -c -w test.cc
test.cc:1:10: error: ‘var’ was not declared in this scope
1 | decltype(var) i = 100;
  |  ^~~
test.cc:1:10: error: ‘var’ was not declared in this scope

While in clang

$clang++ -c -w test.cc
test.cc:1:10: error: use of undeclared identifier 'var'
decltype(var) i = 100;
 ^
1 error generated.


My GCC version is

$g++-trunk --version
g++ (GCC) 11.0.0 20200605 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/95807] New: GCC accepts "void value not ignored as it ought to be" in function template

2020-06-21 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95807

Bug ID: 95807
   Summary: GCC accepts "void value not ignored as it ought to be"
in function template
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: accepts-invalid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

GCC accepts "void value not ignored as it ought to be" in a function template
but rejects it in a normal function definition. 

$cat bug.cc
void foo1() {int var = throw;};
template  
void foo2() {int var = throw;};

$g++ -c bug.cc
bug.cc: In function ‘void foo()’:
bug.cc:1:23: error: void value not ignored as it ought to be
1 | void foo1() {int var = throw;};
  |   ^

Noted that GCC only rejects line 1 but accepts line 3.

In clang
$clang++ -c bug.cc
bug.cc:1:18: error: cannot initialize a variable of type 'int' with an rvalue
of type 'void'
void foo1() {int var = throw;};
 ^ ~
bug.cc:3:18: error: cannot initialize a variable of type 'int' with an rvalue
of type 'void'
void foo2(){ int var = throw;};
 ^ ~
2 errors generated.

My GCC version is
$g++ --version
g++ (GCC) 11.0.0 20200605 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/95807] GCC accepts "void value not ignored as it ought to be" in function template

2020-06-21 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95807

--- Comment #2 from Haoxin Tu  ---
(In reply to Andrew Pinski from comment #1)
> I think it is rejected at instanition time.

Hi, Andrew. Shouldn't it be rejected at compiling time?

Please take a look at another case, test.cc

$cat test.cc
void foo1(int var = throw) {};
template  
void foo2(int var = throw){ };

$g++ -c test.cc
test.cc:1:21: error: could not convert ‘’ from ‘void’ to
‘int’
1 | void foo1(int var = throw){ };
  | ^
  | |
  | void


$clang++ -c test.c
test.cc:1:15: error: cannot initialize a parameter of type 'int' with an rvalue
of type 'void'
void foo1(int var = throw){ };
  ^ ~
test.cc:1:15: note: passing argument to parameter 'var' here
test.cc:3:15: error: cannot initialize a parameter of type 'int' with an rvalue
of type 'void'
void foo2(int var = throw){ };
  ^ ~
test.cc:3:15: note: passing argument to parameter 'var' here
2 errors generated.

Is this case similar with bug.cc?
I guess an "void" can't be a rvalue at any time.

[Bug c++/95809] New: GCC treats inline namespace declaration as "ambiguous"

2020-06-21 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95809

Bug ID: 95809
   Summary: GCC treats inline namespace declaration as "ambiguous"
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code, bug.cc, GCC fails to compile it, while clang, icc, or msvc accepts
it well.

$cat bug.cc
namespace g_namespace {}
inline namespace {
namespace g_namespace {}
}
namespace g_namespace {}

$g++ -c bug.cc
bug.cc:5:12: error: ‘namespace g_namespace’ is ambiguous
5 | namespace  g_namespace {}
  |^~~
bug.cc:3:15: note: candidates are: ‘namespace ::g_namespace { }’
3 | namespace g_namespace {}
  |   ^~~
bug.cc:1:11: note: ‘namespace g_namespace { }’
1 | namespace g_namespace {}
  |   ^~~

My GCC version is
g++ (GCC) 11.0.0 20200605 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


When I remove the keyword "inline", GCC accepts it well. So, I guess GCC might
can not detect the inline namespace declaration and separate its inside
namespace from outside ones.

[Bug c++/95807] GCC accepts "void value not ignored as it ought to be" in function template

2020-06-22 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95807

--- Comment #4 from Haoxin Tu  ---
(In reply to Jonathan Wakely from comment #3)
>  The ill-formed template is not diagnosed unless you instantiate it.
> That is allowed by the standard.

Thank you Jonathan, thanks for your response.

As other major compilers reject this by default, I just suggest GCC should emit
a appropriate diagnostic message (maybe a warning is fine).

Just a suggestion, please understand if it is inappropriate ~

[Bug c++/95807] GCC accepts "void value not ignored as it ought to be" in function template

2020-06-22 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95807

--- Comment #6 from Haoxin Tu  ---
(In reply to Jonathan Wakely from comment #5)

> What practical impact does this have on any real world code?
> Why should we spend time on that, rather than the million other things we
> have to fix?

Hi, Jonathan,
This is the question I am always thinking about. GCC is a big software somehow,
and that's impossible to treat every part equally when it has issues. 


> Obviously in an ideal world GCC would be perfect, but the majority of your
> bug reports are asking for time to be spent on things that just don't matter.

My team nowadays are focusing on improving the quality of mature compilers. We
just developed a tool to test them and then found those bugs. Our method might
not perfect now and it only found some issues in FE, and we are designing a
more effective approach to focus on the ME or BE parts (those parts might more
important for GCC), it still needs some time for us. So I totally agree with
that you said, and maybe later reports will be more useful for you.

> If you really want it fixed, you can always do it yourself:
> https://gcc.gnu.org/contribute.html

This is a really constructive suggestion for me. I will try to do this at some
time.

Anyway, thanks for your kind and helpful response!

[Bug c++/95819] New: ICE: Segmentation fault signal terminated program cc1plus

2020-06-22 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95819

Bug ID: 95819
   Summary: ICE: Segmentation fault signal terminated program
cc1plus
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: ice-on-invalid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This case bug.cc, reduced by C-Reduce, makes GCC crashed.

$cat bug.cc
wchar_t  a  =  [] (struct  {


$g++ bug.cc
bug.cc:1:33: error: types may not be defined in parameter types
1 |  wchar_t  a  =  [] (struct  {
  | ^
bug.cc:2: error: expected ‘}’ at end of input
bug.cc:1:33: note: to match this ‘{’
1 |  wchar_t  a  =  [] (struct  {
  | ^
bug.cc:2: error: expected ‘,’ or ‘...’ at end of input
bug.cc:1:34: error: expected ‘)’ at end of input
1 |  wchar_t  a  =  [] (struct  {
  |~ ^
  |  )
g++: internal compiler error: Segmentation fault signal terminated program
cc1plus
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.

My GCC version
$g++ --version
g++ (GCC) 11.0.0 20200605 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/95820] New: ICE in splice_late_return_type, at cp/pt.c:29034

2020-06-22 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95820

Bug ID: 95820
   Summary: ICE in splice_late_return_type, at cp/pt.c:29034
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: ice-on-invalid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This case bug.cc, reduced by C-Reduce, crashed GCC.

$cat bug.cc
constexpr (*a)()->bool,

$g++ -w -fpermissive small.cc
bug.cc:1:19: internal compiler error: in splice_late_return_type, at
cp/pt.c:29034
1 | constexpr (*a)()->bool,
  |   ^~~~
0x5cd1f6 splice_late_return_type(tree_node*, tree_node*)
../../gcc/cp/pt.c:29034
0x67db9a grokdeclarator(cp_declarator const*, cp_decl_specifier_seq*,
decl_context, int, tree_node**)
../../gcc/cp/decl.c:12154
0x684228 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
../../gcc/cp/decl.c:5231
0x70c8ce cp_parser_init_declarator
../../gcc/cp/parser.c:20817
0x6efcc2 cp_parser_simple_declaration
../../gcc/cp/parser.c:13785
0x7159c6 cp_parser_declaration
../../gcc/cp/parser.c:13484
0x7160b4 cp_parser_translation_unit
../../gcc/cp/parser.c:4761
0x7160b4 c_parse_file()
../../gcc/cp/parser.c:44034
0x7de74b c_common_parse_file()
../../gcc/c-family/c-opts.c:1190
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

My GCC version is
$g++ --version
g++ (GCC) 11.0.0 20200605 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/95820] ICE in splice_late_return_type, at cp/pt.c:29034

2020-06-22 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95820

--- Comment #1 from Haoxin Tu  ---
(In reply to Haoxin Tu from comment #0)

> $g++ -w -fpermissive small.cc

Here is a mistake, and it should be

$g++ -w -fpermissive bug.cc

[Bug c++/95831] New: Wrong line number in " -Wconversion" warning message

2020-06-22 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95831

Bug ID: 95831
   Summary: Wrong line number in " -Wconversion" warning message
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: diagnostic
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
CC: mpolacek at gcc dot gnu.org
  Target Milestone: ---

This code, bug.cc, GCC might emit the wrong line number of the "-Wconversion"
warning.

$cat bug.cc
unsigned a = 0;
void foo (
short  param1 = a,
short  param2 = a,
char param3 = a)
{}

$g++ -Wconversion -c bug.cc
bug.cc:6:20: warning: conversion from 'unsigned int' to 'short int' may change
value [-Wconversion]
6 | char param3 = a)
  |^
bug.cc:6:20: warning: conversion from 'unsigned int' to 'short int' may change
value [-Wconversion]
bug.cc:6:20: warning: conversion from 'unsigned int' to 'char' may change value
[-Wconversion]
Compiler returned: 0

While in Clang:
$clang++ -Wconversion -c bug.cc
bug.cc:3:21: warning: implicit conversion loses integer precision: 'unsigned
int' to 'short' [-Wimplicit-int-conversion]
short  param1 = a,
  ~ ^
bug.cc:4:21: warning: implicit conversion loses integer precision: 'unsigned
int' to 'short' [-Wimplicit-int-conversion]
short  param2 = a,
  ~ ^
bug.cc:5:19: warning: implicit conversion loses integer precision: 'unsigned
int' to 'char' [-Wimplicit-int-conversion]
char param3 = a)
~ ^
3 warnings generated.

Reproduced in godblot: https://godbolt.org/z/AoGkVQ

Noted that I have tested it in almost all GCC versions, they all have this
issue. I guess maybe someone have reported this already, but I can't find one.

[Bug c++/95871] New: Duplicated error message : "the value is not usable in a constant expression"

2020-06-24 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95871

Bug ID: 95871
   Summary: Duplicated error message : "the value is not usable in
a constant expression"
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: diagnostic
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
CC: mpolacek at gcc dot gnu.org
  Target Milestone: ---

This code, bug.cc, GCC emits two duplicated error messages in "the value of ‘a’
is not usable in a constant expression".

$cat bug.cc
long a = 10;
enum E { emator_1 = a } enum_var;

$g++ -c bug.cc
bug.cc:2:21: error: the value of ‘a’ is not usable in a constant expression
2 | enum E { emator_1 = a } enum_var;
  | ^
bug.cc:1:6: note: ‘long int a’ is not const
1 | long a = 10;
  |  ^
bug.cc:2:21: error: the value of ‘a’ is not usable in a constant expression
2 | enum E { emator_1 = a } enum_var;
  | ^
bug.cc:1:6: note: ‘long int a’ is not const
1 | long a = 10;
  |  ^
bug.cc:2:21: error: enumerator value for ‘emator_1’ is not an integer constant
2 | enum E { emator_1 = a } enum_var;
  |   

While in clang
$clang++ -c bug.cc
bug.cc:2:21: error: expression is not an integral constant expression
enum E { emator_1 = a } enum_var;
^
bug.cc:2:21: note: read of non-const variable 'a' is not allowed in a constant
expression
bug.cc:1:6: note: declared here
long a = 10;
 ^
1 error generated.

I have tested in almost all GCC versions, they all have this issue.

[Bug c++/95872] New: Duplicated warning message in "-Wlogical-op"

2020-06-24 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95872

Bug ID: 95872
   Summary: Duplicated warning message in "-Wlogical-op"
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: diagnostic
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
CC: mpolacek at gcc dot gnu.org
  Target Milestone: ---

This code, bug.cc, GCC emits two duplicated warning messages about it.

$cat bug.cc
int a = 10;
decltype(( a or a ) ? 1:0) var = 0;


$g++ -c -Wlogical-op bug.cc
bug.cc:2:14: warning: logical 'or' of equal expressions [-Wlogical-op]

2 | decltype(( a or a ) ? 1:0) var = 0;

  |~~^~~~

bug.cc:2:14: warning: logical 'or' of equal expressions [-Wlogical-op]

All GCC-6 to GCC-trunk versions have this issue.

[Bug c++/95873] New: Duplicated warning message "'class' tag used in naming 'union a'"

2020-06-24 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95873

Bug ID: 95873
   Summary: Duplicated warning message "'class' tag used in naming
'union a'"
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: diagnostic
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
      Reporter: haoxintu at gmail dot com
CC: mpolacek at gcc dot gnu.org
  Target Milestone: ---

This code, bug.cc, GCC emits two duplicated warning messages.

$cat bug.cc
union a{};
auto var = new (typename :: a );

$g++ -c -fpermissive bug.cc
bug.cc:2:29: warning: 'class' tag used in naming 'union a' [-fpermissive]
2 | auto var = new (typename :: a );
  | ^
bug.cc:1:7: note: 'union a' was previously declared here
1 | union a{};
  |   ^
bug.cc:2:29: warning: 'class' tag used in naming 'union a' [-fpermissive]
2 | auto var = new (typename :: a );
  | ^
bug.cc:1:7: note: 'union a' was previously declared here
1 | union a{};
  |   ^

All GCC-6 to GCC-trunk versions have this issue.

[Bug c++/95875] New: Misleading error message "invalid use of incomplete type"

2020-06-24 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95875

Bug ID: 95875
   Summary: Misleading error message "invalid use of incomplete
type"
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: diagnostic
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
CC: mpolacek at gcc dot gnu.org
  Target Milestone: ---

$cat bug.cc
class A: 
public 
A,
A,
A
{} g_class;

$g++ -c bug.cc
bug.cc:5:1: error: invalid use of incomplete type ‘class A’
5 | A
  | ^
bug.cc:1:7: note: forward declaration of ‘class A’
1 | class A:
  |   ^
bug.cc:5:1: error: invalid use of incomplete type ‘class A’
5 | A
  | ^
bug.cc:1:7: note: forward declaration of ‘class A’
1 | class A:
  |   ^
bug.cc:5:1: error: invalid use of incomplete type ‘class A’
5 | A
  | ^
bug.cc:1:7: note: forward declaration of ‘class A’
1 | class A:
  |   ^

While in clang
$clang++ -c bug.cc
bug.cc:3:1: error: base class has incomplete type
A,
^
bug.cc:1:7: note: definition of 'A' is not complete until the closing '}'
class A: 
  ^
1 error generated.

I doubt that how GCC deals with this case. I guess there might be two
situations:
1. GCC gives the wrong line number.
2. GCC just emits the duplicated messages.

I guess GCC might have the second issue. I have tested in almost all GCC
versions, and they all have this issue.

[Bug c++/95892] New: Wrong line number in "-Wsign-conversion" warning message

2020-06-25 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95892

Bug ID: 95892
   Summary: Wrong line number in "-Wsign-conversion" warning
message
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: diagnostic
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
CC: mpolacek at gcc dot gnu.org
  Target Milestone: ---

This code, bug.cc, GCC might give the wrong line number in -Wsign-conversion
warning message.

$cat bug.cc
unsigned int var = 10;
void foo ( 
int a = var, 
int b = var,
int c = var )   
{}

$g++ -c -Wsign-conversion bug.cc 
bug.cc:5:17: warning: conversion to 'int' from 'unsigned int' may change the
sign of the result [-Wsign-conversion]
5 | int c = var )
  | ^
bug.cc:5:17: warning: conversion to 'int' from 'unsigned int' may change the
sign of the result [-Wsign-conversion]
bug.cc:5:17: warning: conversion to 'int' from 'unsigned int' may change the
sign of the result [-Wsign-conversion]

While in clang
$clang++ -c -Wsign-conversion bug.cc 
bug.cc:3:13: warning: implicit conversion changes signedness: 'unsigned int' to
'int' [-Wsign-conversion]
int a = var, 
  ~ ^~~
bug.cc:4:13: warning: implicit conversion changes signedness: 'unsigned int' to
'int' [-Wsign-conversion]
int b = var,
  ~ ^~~
bug.cc:5:13: warning: implicit conversion changes signedness: 'unsigned int' to
'int' [-Wsign-conversion]
int c = var )   
  ~ ^~~
3 warnings generated.

My GCC version is
$g++ --version
g++ (GCC) 11.0.0 20200605 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/95892] Wrong line number in "-Wsign-conversion" warning message

2020-06-26 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95892

--- Comment #3 from Haoxin Tu  ---
(In reply to Jonathan Wakely from comment #1)
> This is a well-known issue where diagnostics in function parameter-lists all
> have the location of the closing brace.

Thank you, Jonathan. 

I guess bug 95831 has the same issue, too.

[Bug c++/95809] GCC treats inline namespace declaration as "ambiguous"

2020-06-26 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95809

--- Comment #3 from Haoxin Tu  ---
(In reply to Nathan Sidwell from comment #2)
> yup, dr2061 made that ill-formed.  
> 
> p1701 (wg21.link/p1701) documents the behaviour and it appears EWG is
> exploring another avenue to resolve the underlying problem 2061 was
> attempting to fix.

Thank you, Nathan, so this is a valid code, right?

[Bug c++/95892] Wrong line number in "-Wsign-conversion" warning message

2020-06-26 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95892

--- Comment #5 from Haoxin Tu  ---
(In reply to Jonathan Wakely from comment #4)
> Yes, thanks, I've closed that one as a duplicate too.

Ok, you are so welcome.

By the way, could you please check other diagnostic issues (bug95871, bug95872,
bug95873, and bug95875) if you are convenient? I guess those might be real bugs
and I tried to find DUP ones but failed. Thank you very much!

[Bug c++/95925] New: ICE in xref_basetypes, at cp/decl.c:15169

2020-06-26 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95925

Bug ID: 95925
   Summary: ICE in xref_basetypes, at cp/decl.c:15169
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: ice-on-invalid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code, bug.cc, reduced by C-Reduce, makes GCC ICE.

$cat bug.cc
class a;
template https://gcc.gnu.org/bugs/> for instructions.


$g++ --version
g++ (GCC) 11.0.0 20200626 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/95927] New: ICE in cp_lexer_new_from_tokens, at cp/parser.c:701

2020-06-26 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95927

Bug ID: 95927
   Summary: ICE in cp_lexer_new_from_tokens, at cp/parser.c:701
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: ice-on-invalid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code, bug.cc, reduced by C-Reduce, makes GCC ICE.

$cat bug.cc
class {
struct a < struct { b ( {

$g++ bug.cc
bug.cc:2:8: error: ‘a’ is not a class template
2 | struct a < struct { b ( {
  |^
bug.cc:2:19: error: types may not be defined in template arguments
2 | struct a < struct { b ( {
  |   ^
bug.cc:2:25: error: expected identifier before ‘{’ token
2 | struct a < struct { b ( {
  | ^
bug.cc:2:24: error: expected ‘)’ before ‘{’ token
2 | struct a < struct { b ( {
  |   ~^~
  |)
bug.cc:2:21: error: ISO C++ forbids declaration of ‘b’ with no type
[]8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-fpermissive-fpermissive]8;;]
2 | struct a < struct { b ( {
  | ^
bug.cc:3: error: expected ‘}’ at end of input
bug.cc:2:19: note: to match this ‘{’
2 | struct a < struct { b ( {
  |   ^
bug.cc:3: error: expected template-argument at end of input
bug.cc:3: error: expected ‘>’ at end of input
bug.cc:3: error: expected ‘{’ or ‘:’ at end of input
bug.cc:3: error: expected ‘{’ at end of input
bug.cc:3: error: expected unqualified-id at end of input
bug.cc:3: error: expected ‘}’ at end of input
bug.cc:1:7: note: to match this ‘{’
1 | class {
  |   ^
bug.cc:3: internal compiler error: in cp_lexer_new_from_tokens, at
cp/parser.c:701
0x641d4d cp_parser_push_lexer_for_tokens
../../gcc/cp/parser.c:701
0x9c2bc5 cp_parser_late_parsing_for_member
../../gcc/cp/parser.c:29944
0x9a0ccb cp_parser_class_specifier_1
../../gcc/cp/parser.c:24230
0x9a1aa3 cp_parser_class_specifier
../../gcc/cp/parser.c:24254
0x9a1aa3 cp_parser_type_specifier
../../gcc/cp/parser.c:17762
0x9a2a02 cp_parser_decl_specifier_seq
../../gcc/cp/parser.c:14410
0x9a35c1 cp_parser_simple_declaration
../../gcc/cp/parser.c:13664
0x9cc926 cp_parser_declaration
../../gcc/cp/parser.c:13484
0x9cd06a cp_parser_translation_unit
../../gcc/cp/parser.c:4761
0x9cd06a c_parse_file()
../../gcc/cp/parser.c:44043
0xae4dbb c_common_parse_file()
../../gcc/c-family/c-opts.c:1190
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.


$g++ --version
g++ (GCC) 11.0.0 20200626 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/95930] New: ICE: Segmentation fault signal terminated program cc1plus

2020-06-26 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95930

Bug ID: 95930
   Summary: ICE: Segmentation fault signal terminated program
cc1plus
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: ice-on-invalid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code, bug.cc, reduced by C-Reduce, makes GCC-trunk ICE with Segmentation
fault signal terminated program cc1plus.

$cat bug.cc
long  a  =  [] ( class {


$g++ bug.cc
bug.cc:1:24: error: types may not be defined in parameter types
1 | long  a  =  [] ( class {
  |^
bug.cc:2: error: expected ‘}’ at end of input
bug.cc:1:24: note: to match this ‘{’
1 | long  a  =  [] ( class {
  |^
bug.cc:2: error: expected ‘,’ or ‘...’ at end of input
bug.cc:1:25: error: expected ‘)’ at end of input
1 | long  a  =  [] ( class {
  |~^
  | )
g++: internal compiler error: Segmentation fault signal terminated program
cc1plus
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.

$g++ --version
g++ (GCC) 11.0.0 20200626 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/95931] New: ICE in dependent_type_p, at cp/pt.c:26326

2020-06-26 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95931

Bug ID: 95931
   Summary: ICE in dependent_type_p, at cp/pt.c:26326
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code, bug.cc, reduced by C-Reduce, makes GCC-trunk ICE.

$cat bug.cc
void a { [] (auto, volatile b


$g++ bug.cc
bug.cc:1:6: error: variable or field ‘a’ declared void
1 | void a { [] (auto, volatile b
  |  ^
bug.cc:1:29: error: ‘b’ does not name a type
1 | void a { [] (auto, volatile b
  | ^
bug.cc:2: error: expected ‘,’ or ‘...’ at end of input
bug.cc:1:30: error: expected ‘)’ at end of input
1 | void a { [] (auto, volatile b
  | ~^
  |  )
bug.cc:2: internal compiler error: in dependent_type_p, at cp/pt.c:26326
0x6551ca dependent_type_p(tree_node*)
../../gcc/cp/pt.c:26326
0x8fc1bb require_complete_types_for_parms
../../gcc/cp/decl.c:13832
0x8fc1bb check_function_type
../../gcc/cp/decl.c:16043
0x8fc1bb start_preparsed_function(tree_node*, tree_node*, int)
../../gcc/cp/decl.c:16257
0x956a15 start_lambda_function(tree_node*, tree_node*)
../../gcc/cp/lambda.c:1425
0x9a912b cp_parser_lambda_body
../../gcc/cp/parser.c:11264
0x9a912b cp_parser_lambda_expression
../../gcc/cp/parser.c:10640
0x9a912b cp_parser_primary_expression
../../gcc/cp/parser.c:5443
0x9b2960 cp_parser_postfix_expression
../../gcc/cp/parser.c:7296
0x99564a cp_parser_binary_expression
../../gcc/cp/parser.c:9609
0x9971ae cp_parser_assignment_expression
../../gcc/cp/parser.c:9914
0x995f6d cp_parser_constant_expression
../../gcc/cp/parser.c:10208
0x9966d1 cp_parser_initializer_clause
../../gcc/cp/parser.c:23272
0x99683a cp_parser_initializer_list
../../gcc/cp/parser.c:23550
0x99683a cp_parser_braced_list
../../gcc/cp/parser.c:23311
0x99aa3a cp_parser_initializer
../../gcc/cp/parser.c:23228
0x9c259b cp_parser_init_declarator
../../gcc/cp/parser.c:20903
0x9a36d2 cp_parser_simple_declaration
../../gcc/cp/parser.c:13785
0x9cc926 cp_parser_declaration
../../gcc/cp/parser.c:13484
0x9cd06a cp_parser_translation_unit
../../gcc/cp/parser.c:4761
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.


$g++ --version
g++ (GCC) 11.0.0 20200626 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/95932] New: ICE in redeclare_class_template, at cp/pt.c:6231

2020-06-26 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95932

Bug ID: 95932
   Summary: ICE in redeclare_class_template, at cp/pt.c:6231
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: ice-on-invalid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code, bug.cc, reduced by C-Reduce, makes GCC-trunk ICE.

$cat bug.cc
template > struct a < class b{}, struct b {

$g++ bug.cc
bug.cc:1:19: error: expected ‘<’ before ‘>>’ token
1 | template > struct a < class b{}, struct b {
  |   ^~
bug.cc:1:19: error: expected identifier before ‘>>’ token
bug.cc:1:19: error: expected ‘>’ before ‘>>’ token
bug.cc:1:19: error: expected ‘class’ or ‘typename’ before ‘>>’ token
bug.cc:1:19: error: expected identifier before ‘>>’ token
bug.cc:1:19: error: expected ‘>’ before ‘>>’ token
bug.cc:1:29: error: ‘a’ is not a class template
1 | template > struct a < class b{}, struct b {
  | ^
bug.cc:1:40: error: types may not be defined in template arguments
1 | template > struct a < class b{}, struct b {
  |^
bug.cc:1:51: internal compiler error: in redeclare_class_template, at
cp/pt.c:6231
1 | template > struct a < class b{}, struct b {
  |   ^
0x652319 redeclare_class_template(tree_node*, tree_node*, tree_node*)
../../gcc/cp/pt.c:6231
0x8fb2e7 xref_tag_1
../../gcc/cp/decl.c:15043
0x8fb440 xref_tag(tag_types, tree_node*, tag_scope, bool)
../../gcc/cp/decl.c:15085
0x9a1584 cp_parser_class_head
../../gcc/cp/parser.c:24658
0x9a1584 cp_parser_class_specifier_1
../../gcc/cp/parser.c:23880
0x9a1aa3 cp_parser_class_specifier
../../gcc/cp/parser.c:24254
0x9a1aa3 cp_parser_type_specifier
../../gcc/cp/parser.c:17762
0x9b6b53 cp_parser_type_specifier_seq
../../gcc/cp/parser.c:22439
0x9afa94 cp_parser_type_id_1
../../gcc/cp/parser.c:22256
0x9b2603 cp_parser_template_type_arg
../../gcc/cp/parser.c:22347
0x9b6ccf cp_parser_template_argument
../../gcc/cp/parser.c:17235
0x9b6ccf cp_parser_template_argument_list
../../gcc/cp/parser.c:17146
0x9b6ccf cp_parser_enclosed_template_argument_list
../../gcc/cp/parser.c:29832
0x9b8cd0 cp_parser_check_for_invalid_template_id
../../gcc/cp/parser.c:3202
0x99ff18 cp_parser_check_for_invalid_template_id
../../gcc/cp/parser.c:3181
0x99ff18 cp_parser_class_head
../../gcc/cp/parser.c:24437
0x99ff18 cp_parser_class_specifier_1
../../gcc/cp/parser.c:23880
0x9a1aa3 cp_parser_class_specifier
../../gcc/cp/parser.c:24254
0x9a1aa3 cp_parser_type_specifier
../../gcc/cp/parser.c:17762
0x9a2a02 cp_parser_decl_specifier_seq
../../gcc/cp/parser.c:14410
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.


$g++ --version
g++ (GCC) 11.0.0 20200626 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/95935] New: ICE : Segmentation fault

2020-06-26 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95935

Bug ID: 95935
   Summary: ICE : Segmentation fault
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: ice-on-invalid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code, bug.cc, reduced by C-Reduce, makes GCC-trunk ICE with Segmentation
fault.

$cat bug.cc
enum struct a;
template  enum struct a {

$g++ bug.cc
bug.cc:2:36: error: expected ‘}’ before ‘;’ token
2 | template ’ before ‘;’ token
bug.cc:2:36: error: expected unqualified-id before ‘;’ token
bug.cc:4: error: expected identifier at end of input
bug.cc:4: error: expected ‘}’ at end of input
bug.cc:3:27: note: to match this ‘{’
3 | template <> enum struct a {
  |   ^
bug.cc:2:35: internal compiler error: Segmentation fault
2 | template https://gcc.gnu.org/bugs/> for instructions.


$g++ --version
g++ (GCC) 11.0.0 20200626 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/95936] New: ICE in splice_late_return_type, at cp/pt.c:29114

2020-06-27 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95936

Bug ID: 95936
   Summary: ICE in splice_late_return_type, at cp/pt.c:29114
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: ice-on-invalid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code, bug.cc. reduced by C-Reduce, makes GCC-trunk ICE.

$cat bug.cc
typedef (*a)()->const =


$g++ -fpermissive -w bug.cc 
bug.cc:1:17: internal compiler error: in splice_late_return_type, at
cp/pt.c:29114
1 | typedef (*a)()->const =
  | ^
0x65832a splice_late_return_type(tree_node*, tree_node*)
../../gcc/cp/pt.c:29114
0x90aab6 grokdeclarator(cp_declarator const*, cp_decl_specifier_seq*,
decl_context, int, tree_node**)
../../gcc/cp/decl.c:12205
0x915628 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
../../gcc/cp/decl.c:5233
0x9c1e6d cp_parser_init_declarator
../../gcc/cp/parser.c:20818
0x9a36d2 cp_parser_simple_declaration
../../gcc/cp/parser.c:13785
0x9cc926 cp_parser_declaration
../../gcc/cp/parser.c:13484
0x9cd06a cp_parser_translation_unit
../../gcc/cp/parser.c:4761
0x9cd06a c_parse_file()
../../gcc/cp/parser.c:44043
0xae4dbb c_common_parse_file()
../../gcc/c-family/c-opts.c:1190
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.


$g++ --version
g++ (GCC) 11.0.0 20200626 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/95937] New: ICE in finish_class_member_access_expr, at cp/typeck.c:3133

2020-06-27 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95937

Bug ID: 95937
   Summary: ICE in finish_class_member_access_expr, at
cp/typeck.c:3133
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: ice-on-invalid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code, bug.cc, reduced by C-Reduce, makes GCC-trunk ICE.

$cat bug.cc
void a { [].decltype(auto)::b

$g++ bug.cc
bug.cc:1:6: error: variable or field ‘a’ declared void
1 | void a { [].decltype(auto)::b
  |  ^
bug.cc: In lambda function:
bug.cc:1:12: error: expected ‘{’ before ‘.’ token
1 | void a { [].decltype(auto)::b
  |^
bug.cc: At global scope:
bug.cc:1:29: internal compiler error: in finish_class_member_access_expr, at
cp/typeck.c:3133
1 | void a { [].decltype(auto)::b
  | ^
0x69a36f finish_class_member_access_expr(cp_expr, tree_node*, bool, int)
../../gcc/cp/typeck.c:3133
0x9b9d27 cp_parser_postfix_dot_deref_expression
../../gcc/cp/parser.c:7900
0x9b2c52 cp_parser_postfix_expression
../../gcc/cp/parser.c:7540
0x99564a cp_parser_binary_expression
../../gcc/cp/parser.c:9609
0x9971ae cp_parser_assignment_expression
../../gcc/cp/parser.c:9914
0x995f6d cp_parser_constant_expression
../../gcc/cp/parser.c:10208
0x9966d1 cp_parser_initializer_clause
../../gcc/cp/parser.c:23272
0x99683a cp_parser_initializer_list
../../gcc/cp/parser.c:23550
0x99683a cp_parser_braced_list
../../gcc/cp/parser.c:23311
0x99aa3a cp_parser_initializer
../../gcc/cp/parser.c:23228
0x9c259b cp_parser_init_declarator
../../gcc/cp/parser.c:20903
0x9a36d2 cp_parser_simple_declaration
../../gcc/cp/parser.c:13785
0x9cc926 cp_parser_declaration
../../gcc/cp/parser.c:13484
0x9cd06a cp_parser_translation_unit
../../gcc/cp/parser.c:4761
0x9cd06a c_parse_file()
../../gcc/cp/parser.c:44043
0xae4dbb c_common_parse_file()
../../gcc/c-family/c-opts.c:1190
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.


$g++ --version
g++ (GCC) 11.0.0 20200626 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/95938] New: ICE in synthesize_implicit_template_parm, at cp/parser.c:44077

2020-06-27 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95938

Bug ID: 95938
   Summary: ICE in synthesize_implicit_template_parm, at
cp/parser.c:44077
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: ice-on-invalid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code, bug.cc, reduced by C-Reduce, makes GCC-trunk ICE.

$cat bug.cc
a ( union { auto


$g++ bug.cc
bug.cc:1:11: error: types may not be defined in parameter types
1 | a ( union { auto
  |   ^
bug.cc:1:13: internal compiler error: in synthesize_implicit_template_parm, at
cp/parser.c:44077
1 | a ( union { auto
  | ^~~~
0x642457 synthesize_implicit_template_parm
../../gcc/cp/parser.c:44077
0x9bd740 cp_parser_simple_type_specifier
../../gcc/cp/parser.c:18029
0x9a1a3d cp_parser_type_specifier
../../gcc/cp/parser.c:17838
0x9a2a02 cp_parser_decl_specifier_seq
../../gcc/cp/parser.c:14410
0x9cb167 cp_parser_member_declaration
../../gcc/cp/parser.c:24995
0x99f921 cp_parser_member_specification_opt
../../gcc/cp/parser.c:24850
0x99f921 cp_parser_class_specifier_1
../../gcc/cp/parser.c:23947
0x9a1aa3 cp_parser_class_specifier
../../gcc/cp/parser.c:24254
0x9a1aa3 cp_parser_type_specifier
../../gcc/cp/parser.c:17762
0x9a2a02 cp_parser_decl_specifier_seq
../../gcc/cp/parser.c:14410
0x9bf3ef cp_parser_parameter_declaration
../../gcc/cp/parser.c:22818
0x9bfdd2 cp_parser_parameter_declaration_list
../../gcc/cp/parser.c:22641
0x9c01bc cp_parser_parameter_declaration_clause
../../gcc/cp/parser.c:22568
0x9ad617 cp_parser_direct_declarator
../../gcc/cp/parser.c:21245
0x9ad617 cp_parser_declarator
../../gcc/cp/parser.c:21109
0x9c1ba6 cp_parser_init_declarator
../../gcc/cp/parser.c:20609
0x9a36d2 cp_parser_simple_declaration
../../gcc/cp/parser.c:13785
0x9cc926 cp_parser_declaration
../../gcc/cp/parser.c:13484
0x9cd06a cp_parser_translation_unit
../../gcc/cp/parser.c:4761
0x9cd06a c_parse_file()
../../gcc/cp/parser.c:44043
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

$g++ --version
g++ (GCC) 11.0.0 20200626 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/95945] New: ICE in poplevel, at cp/decl.c:585

2020-06-28 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95945

Bug ID: 95945
   Summary: ICE in poplevel, at cp/decl.c:585
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: ice-on-invalid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code, bug.cc, reduce by C-Reduce, makes GCC-trunk ICE.

$cat bug.cc
a ( auto struct { b (

$g++ -w bug.cc
bug.cc:1:17: error: types may not be defined in parameter types
1 | a ( auto struct { b (
  | ^
bug.cc:3: error: expected identifier at end of input
bug.cc:3: error: expected ‘,’ or ‘...’ at end of input
bug.cc:1:22: error: expected ‘)’ at end of input
1 | a ( auto struct { b (
  | ~^
  |  )
2 | 
bug.cc:1:19: error: ISO C++ forbids declaration of ‘b’ with no type
[]8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-fpermissive-fpermissive]8;;]
1 | a ( auto struct { b (
  |   ^
bug.cc:3: internal compiler error: in poplevel, at cp/decl.c:585
0x6184a0 poplevel(int, int, int)
../../gcc/cp/decl.c:585
0x9d75b8 end_template_decl()
../../gcc/cp/pt.c:4688
0x989fc2 finish_fully_implicit_template
../../gcc/cp/parser.c:44280
0x9cb99a cp_parser_member_declaration
../../gcc/cp/parser.c:25414
0x99f921 cp_parser_member_specification_opt
../../gcc/cp/parser.c:24850
0x99f921 cp_parser_class_specifier_1
../../gcc/cp/parser.c:23947
0x9a1aa3 cp_parser_class_specifier
../../gcc/cp/parser.c:24254
0x9a1aa3 cp_parser_type_specifier
../../gcc/cp/parser.c:17762
0x9a2a02 cp_parser_decl_specifier_seq
../../gcc/cp/parser.c:14410
0x9bf3ef cp_parser_parameter_declaration
../../gcc/cp/parser.c:22818
0x9bfdd2 cp_parser_parameter_declaration_list
../../gcc/cp/parser.c:22641
0x9c01bc cp_parser_parameter_declaration_clause
../../gcc/cp/parser.c:22568
0x9ad617 cp_parser_direct_declarator
../../gcc/cp/parser.c:21245
0x9ad617 cp_parser_declarator
../../gcc/cp/parser.c:21109
0x9c1ba6 cp_parser_init_declarator
../../gcc/cp/parser.c:20609
0x9a36d2 cp_parser_simple_declaration
../../gcc/cp/parser.c:13785
0x9cc926 cp_parser_declaration
../../gcc/cp/parser.c:13484
0x9cd06a cp_parser_translation_unit
../../gcc/cp/parser.c:4761
0x9cd06a c_parse_file()
../../gcc/cp/parser.c:44043
0xae4dbb c_common_parse_file()
../../gcc/c-family/c-opts.c:1190
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

$g++ --version
g++ (GCC) 11.0.0 20200626 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

This issue may related to bug 90842, bug 92447, and bug 94829, but according to
the backtrace, I guess it's not the same with them.

[Bug c++/95954] New: ICE: unexpected expression ‘(a)’ of kind paren_expr

2020-06-28 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95954

Bug ID: 95954
   Summary: ICE: unexpected expression ‘(a)’ of kind paren_expr
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: error-recovery, ice-on-invalid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code, bug.cc, reduced by C-Reduce, makes GCC-trunk ICE.

$cat bug.cc
short a;
thread_local b ( auto , = ( a ;

$g++ -w bug.cc
bug.cc:2:25: error: expected identifier before ‘=’ token
2 | thread_local b ( auto , = ( a ;
  | ^
bug.cc:2:30: error: expected ‘)’ before ‘;’ token
2 | thread_local b ( auto , = ( a ;
  |   ~  ^~
  |  )
bug.cc:2:30: error: expected ‘)’ before ‘;’ token
2 | thread_local b ( auto , = ( a ;
  |~ ^~
  |  )
bug.cc:2:14: error: ISO C++ forbids declaration of ‘b’ with no type
[]8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-fpermissive-fpermissive]8;;]
2 | thread_local b ( auto , = ( a ;
  |  ^
bug.cc:2:31: internal compiler error: unexpected expression ‘(a)’ of kind
paren_expr
2 | thread_local b ( auto , = ( a ;
  |   ^
0x8b06d4 cxx_eval_constant_expression
../../gcc/cp/constexpr.c:6503
0x8b0c1f cxx_eval_outermost_constant_expr
../../gcc/cp/constexpr.c:6708
0x8b500b maybe_constant_value(tree_node*, tree_node*, bool)
../../gcc/cp/constexpr.c:6981
0x8ddc74 cp_fully_fold(tree_node*)
../../gcc/cp/cp-gimplify.c:2464
0x8e51cf cp_convert_and_check(tree_node*, tree_node*, int)
../../gcc/cp/cvt.c:661
0x8724df convert_like_real
../../gcc/cp/call.c:7865
0x873c29 perform_implicit_conversion_flags(tree_node*, tree_node*, int, int)
../../gcc/cp/call.c:11870
0x8f887f check_default_argument(tree_node*, tree_node*, int)
../../gcc/cp/decl.c:13923
0x8f8edf grokparms(tree_node*, tree_node**)
../../gcc/cp/decl.c:14111
0x90a23b grokdeclarator(cp_declarator const*, cp_decl_specifier_seq*,
decl_context, int, tree_node**)
../../gcc/cp/decl.c:12393
0x915628 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
../../gcc/cp/decl.c:5233
0x9c1e6d cp_parser_init_declarator
../../gcc/cp/parser.c:20818
0x9a36d2 cp_parser_simple_declaration
../../gcc/cp/parser.c:13785
0x9cc926 cp_parser_declaration
../../gcc/cp/parser.c:13484
0x9cd06a cp_parser_translation_unit
../../gcc/cp/parser.c:4761
0x9cd06a c_parse_file()
../../gcc/cp/parser.c:44043
0xae4dbb c_common_parse_file()
../../gcc/c-family/c-opts.c:1190
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

$g++ --version
g++ (GCC) 11.0.0 20200626 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/95955] New: ICE: tree check: expected integer_type or enumeral_type or boolean_type or real_type or fixed_point_type, have union_type in int_fits_type_p, at tree.c:8952

2020-06-28 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95955

Bug ID: 95955
   Summary: ICE: tree check: expected integer_type or
enumeral_type or boolean_type or real_type or
fixed_point_type, have union_type in int_fits_type_p,
at tree.c:8952
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: error-recovery, ice-on-invalid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code, bug.cc, reduced by C-Reduce, makes GCC-trunk ICE.

$cat bug.cc
enum class a : struct {}
template < < > > enum class a : union b {}
enum class a { c

$g++ bug.cc
bug.cc:1:25: error: expected ‘;’ after struct definition
1 | enum class a : struct {}
  | ^
  | ;
bug.cc:1:24: error: underlying type ‘’ of ‘a’ must be an
integral type
1 | enum class a : struct {}
  |^
bug.cc:2:12: error: expected identifier before ‘<’ token
2 | template < < > > enum class a : union b {}
  |^
bug.cc:2:12: error: expected ‘>’ before ‘<’ token
bug.cc:2:43: error: expected ‘;’ after union definition
2 | template < < > > enum class a : union b {}
  |   ^
  |   ;
bug.cc:3:12: error: different underlying type in enum ‘enum class a’
3 | enum class a { c
  |^
bug.cc:1:24: note: previous definition here
1 | enum class a : struct {}
  |^
bug.cc:3:16: internal compiler error: tree check: expected integer_type or
enumeral_type or boolean_type or real_type or fixed_point_type, have union_type
in int_fits_type_p, at tree.c:8952
3 | enum class a { c
  |^
0x7c2dcf tree_check_failed(tree_node const*, char const*, int, char const*,
...)
../../gcc/tree.c:9685
0x7c9ce1 tree_check5(tree_node const*, char const*, int, char const*,
tree_code, tree_code, tree_code, tree_code, tree_code)
../../gcc/tree.h:3648
0x7c9ce1 int_fits_type_p(tree_node const*, tree_node const*)
../../gcc/tree.c:8952
0x911daa build_enumerator(tree_node*, tree_node*, tree_node*, tree_node*,
unsigned int)
../../gcc/cp/decl.c:15906
0x9a2447 cp_parser_enumerator_definition
../../gcc/cp/parser.c:19545
0x9a2447 cp_parser_enumerator_list
../../gcc/cp/parser.c:19474
0x9a2447 cp_parser_enum_specifier
../../gcc/cp/parser.c:19405
0x9a2447 cp_parser_type_specifier
../../gcc/cp/parser.c:17734
0x9a2a02 cp_parser_decl_specifier_seq
../../gcc/cp/parser.c:14410
0x9a35c1 cp_parser_simple_declaration
../../gcc/cp/parser.c:13664
0x9cc926 cp_parser_declaration
../../gcc/cp/parser.c:13484
0x9cd06a cp_parser_translation_unit
../../gcc/cp/parser.c:4761
0x9cd06a c_parse_file()
../../gcc/cp/parser.c:44043
0xae4dbb c_common_parse_file()
../../gcc/c-family/c-opts.c:1190
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.


$g++ --version
g++ (GCC) 11.0.0 20200626 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/95956] New: ICE in check_bases, at cp/class.c:1689

2020-06-28 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95956

Bug ID: 95956
   Summary: ICE in check_bases, at cp/class.c:1689
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: error-recovery, ice-on-invalid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code, bug.cc, reduced by C-Reduce, makes GCC-trunk ICE.

$cat bug.cc
a ( auto struct : decltype ( auto  ) { {

$g++ bug.cc
bug.cc:1:5: warning: use of ‘auto’ in parameter declaration only available with
‘-fconcepts-ts’
1 | a ( auto struct : decltype ( auto  ) { {
  | ^~~~
bug.cc:1:38: error: types may not be defined in parameter types
1 | a ( auto struct : decltype ( auto  ) { {
  |  ^
bug.cc:1:40: error: expected unqualified-id before ‘{’ token
1 | a ( auto struct : decltype ( auto  ) { {
  |^
bug.cc:2: error: expected ‘}’ at end of input
bug.cc:1:38: note: to match this ‘{’
1 | a ( auto struct : decltype ( auto  ) { {
  |  ^
bug.cc:1:17: internal compiler error: in check_bases, at cp/class.c:1689
1 | a ( auto struct : decltype ( auto  ) { {
  | ^
0x5ed0ac check_bases
../../gcc/cp/class.c:1689
0x5ed0ac check_bases_and_members
../../gcc/cp/class.c:5900
0x89eca3 finish_struct_1(tree_node*)
../../gcc/cp/class.c:7269
0x8a06d4 finish_struct(tree_node*, tree_node*)
../../gcc/cp/class.c:7573
0x99f973 cp_parser_class_specifier_1
../../gcc/cp/parser.c:23955
0x9a1aa3 cp_parser_class_specifier
../../gcc/cp/parser.c:24254
0x9a1aa3 cp_parser_type_specifier
../../gcc/cp/parser.c:17762
0x9a2a02 cp_parser_decl_specifier_seq
../../gcc/cp/parser.c:14410
0x9bf3ef cp_parser_parameter_declaration
../../gcc/cp/parser.c:22818
0x9bfdd2 cp_parser_parameter_declaration_list
../../gcc/cp/parser.c:22641
0x9c01bc cp_parser_parameter_declaration_clause
../../gcc/cp/parser.c:22568
0x9ad617 cp_parser_direct_declarator
../../gcc/cp/parser.c:21245
0x9ad617 cp_parser_declarator
../../gcc/cp/parser.c:21109
0x9c1ba6 cp_parser_init_declarator
../../gcc/cp/parser.c:20609
0x9a36d2 cp_parser_simple_declaration
../../gcc/cp/parser.c:13785
0x9cc926 cp_parser_declaration
../../gcc/cp/parser.c:13484
0x9cd06a cp_parser_translation_unit
../../gcc/cp/parser.c:4761
0x9cd06a c_parse_file()
../../gcc/cp/parser.c:44043
0xae4dbb c_common_parse_file()
../../gcc/c-family/c-opts.c:1190
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

$g++ --version
g++ (GCC) 11.0.0 20200626 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/95972] New: ICE in check_member_template, at cp/decl2.c:570

2020-06-29 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95972

Bug ID: 95972
   Summary: ICE in check_member_template, at cp/decl2.c:570
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: error-recovery, ice-on-invalid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code, bug.cc, reduced by C-Reduce, makes GCC-trunk ICE.

$cat bug.cc
a() { [] ( struct { b ( auto

$g++ -w bug.cc
bug.cc:1:1: error: ISO C++ forbids declaration of ‘a’ with no type
[]8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-fpermissive-fpermissive]8;;]
1 | a() { [] ( struct { b ( auto
  | ^
bug.cc: In function ‘int a()’:
bug.cc:1:19: error: types may not be defined in parameter types
1 | a() { [] ( struct { b ( auto
  |   ^
bug.cc:2: error: expected ‘,’ or ‘...’ at end of input
bug.cc:1:29: error: expected ‘)’ at end of input
1 | a() { [] ( struct { b ( auto
  |   ~ ^
  | )
bug.cc:1:21: error: ISO C++ forbids declaration of ‘b’ with no type
[]8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-fpermissive-fpermissive]8;;]
1 | a() { [] ( struct { b ( auto
  | ^
bug.cc:2: internal compiler error: in check_member_template, at cp/decl2.c:570
0x61d665 check_member_template(tree_node*)
../../gcc/cp/decl2.c:570
0x9d3490 finish_member_template_decl(tree_node*)
../../gcc/cp/pt.c:308
0x989fba finish_fully_implicit_template
../../gcc/cp/parser.c:44279
0x9cb99a cp_parser_member_declaration
../../gcc/cp/parser.c:25414
0x99f921 cp_parser_member_specification_opt
../../gcc/cp/parser.c:24850
0x99f921 cp_parser_class_specifier_1
../../gcc/cp/parser.c:23947
0x9a1aa3 cp_parser_class_specifier
../../gcc/cp/parser.c:24254
0x9a1aa3 cp_parser_type_specifier
../../gcc/cp/parser.c:17762
0x9a2a02 cp_parser_decl_specifier_seq
../../gcc/cp/parser.c:14410
0x9bf3ef cp_parser_parameter_declaration
../../gcc/cp/parser.c:22818
0x9bfdd2 cp_parser_parameter_declaration_list
../../gcc/cp/parser.c:22641
0x9c01bc cp_parser_parameter_declaration_clause
../../gcc/cp/parser.c:22568
0x9c0bae cp_parser_lambda_declarator_opt
../../gcc/cp/parser.c:11102
0x9a8836 cp_parser_lambda_expression
../../gcc/cp/parser.c:10633
0x9a8836 cp_parser_primary_expression
../../gcc/cp/parser.c:5443
0x9b2960 cp_parser_postfix_expression
../../gcc/cp/parser.c:7296
0x99564a cp_parser_binary_expression
../../gcc/cp/parser.c:9609
0x9971ae cp_parser_assignment_expression
../../gcc/cp/parser.c:9914
0x9974d2 cp_parser_expression
../../gcc/cp/parser.c:10082
0x99a368 cp_parser_expression_statement
../../gcc/cp/parser.c:11742
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

$g++ --version
g++ (GCC) 11.0.0 20200626 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/95972] ICE in check_member_template, at cp/decl2.c:570

2020-07-02 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95972

--- Comment #1 from Haoxin Tu  ---
Hi, there.

I guess I shouldn't use C-Reduce to reduce my ICE on invalid code cases. After
using C-Reduce, the cases are more like a "garbage" code.

Here is a more readable code to reproduce the ICE.

$cat p.cc
int a() { 
auto var = [] ( struct s{ int b( auto);} ){};
}

$g++ -w p.cc
p.cc: In function ‘int a()’:
p.cc:2:29: error: types may not be defined in parameter types
2 | auto var = [] ( struct s{ int b( auto);} ){};
  | ^
p.cc:2:42: internal compiler error: in check_member_template, at cp/decl2.c:570
2 | auto var = [] ( struct s{ int b( auto);} ){};
  |  ^
0x6890c4 check_member_template(tree_node*)
../../gcc/cp/decl2.c:570
0xa41c20 finish_member_template_decl(tree_node*)
../../gcc/cp/pt.c:308
0x9f86ba finish_fully_implicit_template
../../gcc/cp/parser.c:44279
0xa3a12a cp_parser_member_declaration
../../gcc/cp/parser.c:25414
0xa0e061 cp_parser_member_specification_opt
../../gcc/cp/parser.c:24850
0xa0e061 cp_parser_class_specifier_1
../../gcc/cp/parser.c:23947
0xa10213 cp_parser_class_specifier
../../gcc/cp/parser.c:24254
0xa10213 cp_parser_type_specifier
../../gcc/cp/parser.c:17762
0xa11172 cp_parser_decl_specifier_seq
../../gcc/cp/parser.c:14410
0xa2db8f cp_parser_parameter_declaration
../../gcc/cp/parser.c:22818
0xa2e582 cp_parser_parameter_declaration_list
../../gcc/cp/parser.c:22641
0xa2e95c cp_parser_parameter_declaration_clause
../../gcc/cp/parser.c:22568
0xa2f34e cp_parser_lambda_declarator_opt
../../gcc/cp/parser.c:11102
0xa16fb8 cp_parser_lambda_expression
../../gcc/cp/parser.c:10633
0xa16fb8 cp_parser_primary_expression
../../gcc/cp/parser.c:5443
0xa21110 cp_parser_postfix_expression
../../gcc/cp/parser.c:7296
0xa03d6a cp_parser_binary_expression
../../gcc/cp/parser.c:9609
0xa058ce cp_parser_assignment_expression
../../gcc/cp/parser.c:9914
0xa0468d cp_parser_constant_expression
../../gcc/cp/parser.c:10208
0xa04df1 cp_parser_initializer_clause
../../gcc/cp/parser.c:23272
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

While in Clang
$clang++ -w p.cc
p.cc:2:28: error: 's' cannot be defined in a parameter type
auto var = [] ( struct s{ int b( auto);} ){};
   ^
1 error generated.

The ICE just cased by the struct used as a lambda expression parameter. And ICE
point out the parser can not deal with the "auto" keywords and then crashed on
it.

[Bug c++/95945] ICE in poplevel, at cp/decl.c:585

2020-07-02 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95945

--- Comment #1 from Haoxin Tu  ---
Add a more meaningful case

$cat p.cc
int a ( auto struct x { int b ();}) {}

$g++ -w p.cc
p.cc:1:23: error: types may not be defined in parameter types
1 | int a ( auto struct x { int b ();}) {}
  |   ^
p.cc:1:32: internal compiler error: in poplevel, at cp/decl.c:585
1 | int a ( auto struct x { int b ();}) {}
  |^
0x683eae poplevel(int, int, int)
../../gcc/cp/decl.c:585
0xa45d68 end_template_decl()
../../gcc/cp/pt.c:4688
0x9f86c2 finish_fully_implicit_template
../../gcc/cp/parser.c:44280
0xa3a12a cp_parser_member_declaration
../../gcc/cp/parser.c:25414
0xa0e061 cp_parser_member_specification_opt
../../gcc/cp/parser.c:24850
0xa0e061 cp_parser_class_specifier_1
../../gcc/cp/parser.c:23947
0xa10213 cp_parser_class_specifier
../../gcc/cp/parser.c:24254
0xa10213 cp_parser_type_specifier
../../gcc/cp/parser.c:17762
0xa11172 cp_parser_decl_specifier_seq
../../gcc/cp/parser.c:14410
0xa2db8f cp_parser_parameter_declaration
../../gcc/cp/parser.c:22818
0xa2e582 cp_parser_parameter_declaration_list
../../gcc/cp/parser.c:22641
0xa2e95c cp_parser_parameter_declaration_clause
../../gcc/cp/parser.c:22568
0xa1bda7 cp_parser_direct_declarator
../../gcc/cp/parser.c:21245
0xa1bda7 cp_parser_declarator
../../gcc/cp/parser.c:21109
0xa30346 cp_parser_init_declarator
../../gcc/cp/parser.c:20609
0xa11e42 cp_parser_simple_declaration
../../gcc/cp/parser.c:13785
0xa3b0b6 cp_parser_declaration
../../gcc/cp/parser.c:13484
0xa3b7fa cp_parser_translation_unit
../../gcc/cp/parser.c:4761
0xa3b7fa c_parse_file()
../../gcc/cp/parser.c:44043
0xb5473b c_common_parse_file()
../../gcc/c-family/c-opts.c:1190
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

In Clang
$clang++ -w p.cc
p.cc:1:21: error: 'x' cannot be defined in a parameter type
int a ( auto struct x { int b ();}) {}
^
1 error generated.

[Bug c++/95956] ICE in check_bases, at cp/class.c:1689

2020-07-02 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95956

W E Brown  changed:

   What|Removed |Added

 CC||webrown.cpp at gmail dot com

--- Comment #1 from Haoxin Tu  ---
Add a more readable case.

$cat p.cc
int a ( auto struct : decltype ( auto ) {{}}){}


$g++ -w p.cc
p.cc:1:41: error: types may not be defined in parameter types
1 | int a ( auto struct : decltype ( auto ) {{}}){}
  | ^
p.cc:1:42: error: expected unqualified-id before ‘{’ token
1 | int a ( auto struct : decltype ( auto ) {{}}){}
  |  ^
p.cc:1:21: internal compiler error: in check_bases, at cp/class.c:1689
1 | int a ( auto struct : decltype ( auto ) {{}}){}
  | ^
0x658963 check_bases
../../gcc/cp/class.c:1689
0x658963 check_bases_and_members
../../gcc/cp/class.c:5900

[Bug c++/95955] ICE: tree check: expected integer_type or enumeral_type or boolean_type or real_type or fixed_point_type, have union_type in int_fits_type_p, at tree.c:8952

2020-07-02 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95955

W E Brown  changed:

   What|Removed |Added

 CC||webrown.cpp at gmail dot com

--- Comment #1 from Haoxin Tu  ---
Add a more readable case

$cat p.c
enum class a : struct{};
template < template  class A > 
enum class a : union b {};
enum class a { c;}

$g++ p.cc
p.cc:1:23: error: underlying type ‘’ of ‘a’ must be an integral
type
1 | enum class a : struct{};
  |   ^
p.cc:4:12: error: different underlying type in enum ‘enum class a’
4 | enum class a { c;}
  |^
p.cc:1:23: note: previous definition here
1 | enum class a : struct{};
  |   ^
p.cc:4:16: internal compiler error: tree check: expected integer_type or
enumeral_type or boolean_type or real_type or fixed_point_type, have union_type
in int_fits_type_p, at tree.c:8952
4 | enum class a { c;}
  |^

[Bug c++/95931] ICE in dependent_type_p, at cp/pt.c:26326

2020-07-02 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95931

--- Comment #1 from Haoxin Tu  ---
Add a more meaningful case.

$cat p.cc
void a() { 
auto var = [] (auto, volatile b) {};
}

$g++ p.cc
p.cc: In function ‘void a()’:
p.cc:2:35: error: ‘b’ does not name a type
2 | auto var = [] (auto, volatile b) {};
  |   ^
p.cc:2:40: error: expected ‘)’ before ‘;’ token
2 | auto var = [] (auto, volatile b) {};
  |   ~^
  |)
p.cc:2:40: internal compiler error: in dependent_type_p, at cp/pt.c:26326
0x6c0f63 dependent_type_p(tree_node*)
../../gcc/cp/pt.c:26326

While in Clang
$clang++ p.cc
p.cc:2:35: error: unknown type name 'b'
auto var = [] (auto, volatile b) {};
  ^
1 error generated.

Noted that why GCC emits "expected ‘)’ before ‘;’ token" and has an ICE on the
";"?

Also, this situation may happen in the real world when someone just leaves a
type specifier out by a mistake.

[Bug c++/95927] ICE in cp_lexer_new_from_tokens, at cp/parser.c:701

2020-07-02 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95927

--- Comment #1 from Haoxin Tu  ---
Add a more meaningful case.


$cat p.cc
template  struct a {};
class A {
struct a < struct x { void b ( ){}} >;
};

$g++ p.cc
p.cc:3:25: error: types may not be defined in template arguments
3 | struct a < struct x { void b ( ){}} >;
  | ^
p.cc:3:40: error: expected ‘;’ after struct definition
3 | struct a < struct x { void b ( ){}} >;
  |^
  |;
p.cc:3:39: error: expected template-argument before ‘;’ token
3 | struct a < struct x { void b ( ){}} >;
  |   ^
p.cc:3:39: error: expected ‘>’ before ‘;’ token
p.cc:3:5: error: ‘struct a’ redeclared with different access
3 | struct a < struct x { void b ( ){}} >;
  | ^~
p.cc:3:41: error: expected unqualified-id before ‘>’ token
3 | struct a < struct x { void b ( ){}} >;
  | ^
p.cc:4:1: internal compiler error: in cp_lexer_new_from_tokens, at
cp/parser.c:701
4 | };
  | ^
0x6adadc cp_parser_push_lexer_for_tokens
../../gcc/cp/parser.c:701
...


While in Clang
$clang++ p.cc
p.cc:3:23: error: 'x' cannot be defined in a type specifier
struct a < struct x { void b ( ){}} >;
  ^
1 error generated.

I guess Clang is performed better when parsing this case. GCC emits a lot of
error messages even throw an ICE, while Clang just emits one.

[Bug c++/95932] ICE in redeclare_class_template, at cp/pt.c:6231

2020-07-02 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95932

--- Comment #1 from Haoxin Tu  ---
Add a more meaningful case.

$cat p.cc
template  class a {};
template  > 
struct a < class b{}, struct b {}>;

$g++ p.cc
p.cc:2:28: error: expected ‘class’ or ‘typename’ before ‘>’ token
2 | template  >
  |^
p.cc:3:19: error: types may not be defined in template arguments
3 | struct a < class b{}, struct b {}>;
  |   ^
p.cc:3:30: internal compiler error: in redeclare_class_template, at
cp/pt.c:6231
3 | struct a < class b{}, struct b {}>;
  |  ^
0x6be12f redeclare_class_template(tree_node*, tree_node*, tree_node*)
../../gcc/cp/pt.c:6231
...

While in Clang
$clang++ p.cc
p.cc:2:28: error: template template parameter requires 'class' after the
parameter list
template  > 
   ^
   class 
p.cc:3:18: error: 'b' cannot be defined in a type specifier
struct a < class b{}, struct b {}>;
 ^
2 errors generated.

I guess this is also a possible issue that users may encounter in programming,
but it makes GCC crashed.

[Bug c++/96045] New: Wrong line and column diagnostic message in a class template instantiation

2020-07-03 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96045

Bug ID: 96045
   Summary: Wrong line and column diagnostic message in a class
template instantiation
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: diagnostic
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This simple code, bug.cc, GCC-trunk can not emit the right diagnostic
information.

$cat bug.cc
template  class A {};
struct A  

$g++ -c bug.cc
bug.cc:3: error: expected unqualified-id at end of input

Noted that the number 3 is not a line number nor a column number.

While in Clang
$clang++ -c bug.cc
bug.cc:2:16: error: expected unqualified-id
struct A  
   ^
1 error generated.

$g++ --version
g++ (GCC) 11.0.0 20200630 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/96048] New: ICE in get_local_decls, at cp/name-lookup.c:3591

2020-07-03 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96048

Bug ID: 96048
   Summary: ICE in get_local_decls, at cp/name-lookup.c:3591
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: ice-on-invalid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This invalid code, bug.cc, makes GCC-trunk ICE.

$cat bug.cc
struct a {template  class A;};
a : b ( auto ) ( class { });


$g++ -c -w bug.cc
bug.cc:2:3: error: found ‘:’ in nested-name-specifier, expected ‘::’
2 | a : b ( auto ) ( class { });
  |   ^
  |   ::
bug.cc:2:18: error: template definition of non-template ‘struct a::’
2 | a : b ( auto ) ( class { });
  |  ^
bug.cc:2:27: internal compiler error: in get_local_decls, at
cp/name-lookup.c:3591
2 | a : b ( auto ) ( class { });
  |   ^
0x63d349 get_local_decls()
../../gcc/cp/name-lookup.c:3591
0x97a185 pop_bindings_and_leave_scope()
../../gcc/cp/name-lookup.c:2065
0x9b0969 cp_parser_direct_declarator
../../gcc/cp/parser.c:21336
0x9b0969 cp_parser_declarator
../../gcc/cp/parser.c:21109
0x9c4ca6 cp_parser_init_declarator
../../gcc/cp/parser.c:20609
0x9a67a2 cp_parser_simple_declaration
../../gcc/cp/parser.c:13785
0x9cfa16 cp_parser_declaration
../../gcc/cp/parser.c:13484
0x9d015a cp_parser_translation_unit
../../gcc/cp/parser.c:4761
0x9d015a c_parse_file()
../../gcc/cp/parser.c:44043
0xae920b c_common_parse_file()
../../gcc/c-family/c-opts.c:1190
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

$g++ --version
++ (GCC) 11.0.0 20200630 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[Bug c++/96057] New: -Wreturn-type warning message disappears with -O1 to -Os in unnamed namespace definition

2020-07-04 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96057

Bug ID: 96057
   Summary: -Wreturn-type warning message disappears with -O1 to
-Os in unnamed namespace definition
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

Hi, all.

This small code, bug.cc, the -Wreturn-type warning disappears when add -O1 or
higher optimization option.

$cat bug.cc
namespace {
int foo() { 1 ? 0 : throw 0 ; }
}

$g++ -c -Wreturn-type -O0 bug.cc
bug.cc: In function 'int {anonymous}::foo()':
bug.cc:2:35: warning: control reaches end of non-void function [-Wreturn-type]
2 | int foo() { 1 ? 0 : throw 0 ; }
  |   

$g++ -c -Wreturn-type -O1 bug.cc
//emit nothing with -O1 to -Os option

While in Clang, the output of -O0 to -Os is the same. For example,

$clang++ -c -Wreturn-type -O1 bug.cc
bug.cc:2:35: warning: non-void function does not return a value [-Wreturn-type]
int foo() { 1 ? 0 : throw 0 ; }
  ^
1 warning generated.


$g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/home/haoxin/corpus-compilers/gcc-trunk/gcc-master/build/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure
--prefix=/home/haoxin/corpus-compilers/gcc-trunk/gcc-master/build/
--enable-languages=c,c++ CC=gcc CXX=g++
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20200630 (experimental) (GCC)

[Bug c++/96068] New: Extra semicolon outside of a function should be allowed after c++11?

2020-07-05 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96068

Bug ID: 96068
   Summary: Extra semicolon outside of a function should be
allowed after c++11?
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: diagnostic
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

Hi, all.

As the summary, extra ";" should be allowed in GCC after -std=c++11 and
shouldn't give a diagnostic message about it? I know this is forbidden in
c++98.

For example,

$cat test.cc
void foo() { };

$g++ -c -std=c++98 -pedantic-errors test.cc
test.cc:1:16: error: extra ';' [-Wpedantic]
1 | void foo () { };
  |^

$g++ -c -std=c++11 -pedantic-errors test.cc
test.cc:1:16: error: extra ';' [-Wpedantic]
1 | void foo () { };
  |^

While in Clang, this is accepted in c++11 or later.

$clang++ -c -std=c++98 -pedantic-errors test.cc
test.cc:1:15: error: extra ';' outside of a function is a C++11 extension
[-Werror,-Wc++11-extra-semi]
void foo() { };
  ^
1 error generated.

There is also a related bug report in llvm: 

https://bugs.llvm.org/show_bug.cgi?id=46288

They suggested that "If GCC rejects this under -pedantic-errors in C++11 or
later, I think that's a GCC bug."

I try to find a similar bug report in GCC but failed. 

Did I miss something? Thank you very much.

[Bug c++/96077] New: GCC accepts ill-legal local enum definition

2020-07-06 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96077

Bug ID: 96077
   Summary: GCC accepts ill-legal local enum definition
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: accepts-invalid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

Hi, all.

This code, test.cc, has a grammar issue in "missing ')'", but GCC accepts it
well.

$cat test.cc
enum { a = ( 1 ) ? ( 2 ) : ( 2 + 1 } g_e; //reject
int main () {
enum { a = ( 1 ) ? ( 2 ) : ( 2 + 1 /* missing ")" here */ } l_e; //accept
return 0;
}

$g++ test.cc
test.cc:1:35: error: expected ‘)’ before ‘}’ token
1 | enum { a = ( 1 ) ? ( 2 ) : ( 2 + 1 } g_e; //reject
  |~  ^~
  |  )

GCC only rejects line 1 but accepts line 3.

While in Clang

$clang++ test.cc
test.cc:1:36: error: expected ')'
enum { a = ( 1 ) ? ( 2 ) : ( 2 + 1 } g_e; //reject
   ^
test.cc:1:28: note: to match this '('
enum { a = ( 1 ) ? ( 2 ) : ( 2 + 1 } g_e; //reject
   ^
test.cc:3:63: error: expected ')'
enum { a = ( 1 ) ? ( 2 ) : ( 2 + 1 /* missing ")" here */ } l_e; //accept
  ^
test.cc:3:32: note: to match this '('
enum { a = ( 1 ) ? ( 2 ) : ( 2 + 1 /* missing ")" here */ } l_e; //accept
   ^
2 errors generated.


$g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/home/haoxin/corpus-compilers/gcc-trunk/gcc-master/build/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure
--prefix=/home/haoxin/corpus-compilers/gcc-trunk/gcc-master/build/
--enable-languages=c,c++ CC=gcc CXX=g++
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20200630 (experimental) (GCC)

[Bug c++/96077] GCC accepts ill-legal local enum definition

2020-07-06 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96077

--- Comment #2 from Haoxin Tu  ---
(In reply to Jonathan Wakely from comment #1)
> It's not ideal to provide a testcase that doesn't compile for an
> accepts-invalid bug. A testcase that actually compiles is a better
> demonstration that the invalid code is accepted

OK, I got it. Thank you Jonathan. I will do better next time.

[Bug c++/96082] New: GCC rejects the template disambiguator with "typename"

2020-07-06 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96082

Bug ID: 96082
   Summary: GCC rejects the template disambiguator with "typename"
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

Hi, all.

This code, test.cc, GCC rejects it in versions from 9.1 to trunk, but accepts
it from 8.3 to 4.8 versions. 

$cat test.cc
template  class A {};
int main () { 
typename :: template A  a;
}

$g++ test.cc
test.cc: In function ‘int main()’:
test.cc:3:26: error: ‘template’ must follow a nested-name-specifier
3 | typename :: template A  a;
  |  ^~~
test.cc:3:26: error: expected ‘(’
3 | typename :: template A  a;
  |  ^~~
  |

I also tested in clang, icc, and msvc, they all accept this code.

[Bug c++/96103] New: Unclear diagnostic for a function return with "decltype(auto)"

2020-07-07 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96103

Bug ID: 96103
   Summary: Unclear diagnostic for a function return with
"decltype(auto)"
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: diagnostic
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

Hi, all.

This code, "decltype(auto)" in return type is a c++14 extension and I guess GCC
might diagnose this better. 

$cat test.cc
decltype(auto) foo () {}

$g++ -c -std=c++11 test.cc
test.cc:1:10: error: expected primary-expression before ‘auto’
1 | decltype(auto) foo () {}
  |  ^~~~
test.cc: In function ‘int foo()’:
test.cc:1:24: warning: no return statement in function returning non-void
[-Wreturn-type]
1 | decltype(auto) foo () {}
  |^

$g++ -c -std=c++14 test.cc
//emits nothing

While in Clang:
$clang++ -c -std=c++11 test.cc 
test.cc:1:10: warning: 'decltype(auto)' type specifier is a C++14 extension
[-Wc++14-extensions]
decltype(auto) foo () {}
 ^
test.cc:1:1: error: deduced return types are a C++14 extension
decltype(auto) foo () {}
^
1 warning and 1 error generated.

I guess users can not fix the code according to the errors emitted until they
realized this is a C++14 extension. 

Should GCC recognizes the C++14 extension first when parsing this code and then
emits the appropriate diagnostic information?

Thanks,
Haoxin

[Bug c++/96097] ICE in dependent_type_p, at cp/pt.c:26326

2020-07-08 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96097

Haoxin Tu  changed:

   What|Removed |Added

 CC||haoxintu at gmail dot com

--- Comment #3 from Haoxin Tu  ---
(In reply to Martin Liška from comment #2)
> Confirmed, clang accepts the code. GCC ICEs for all revisions.

Hi,

I just realized I have reported an ice-on-invalid version in bug 95931 with the
same symptom in the trunk. Maybe you can consider them together.

Thanks,
Haoxin

[Bug c++/96110] New: Function declarator with a trailing return type "auto" should be allowed in try-catch block

2020-07-08 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96110

Bug ID: 96110
   Summary: Function declarator with a trailing return type "auto"
should be allowed in try-catch block
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

Hi, all.

The code test.cc

int main(){
try {}
catch (auto foo() -> auto) {}
return 0;
}


might should be allowed in GCC.

$g++ test.cc
test.cc: In function 'int main()':
test.cc:8:12: error: 'auto' parameter not permitted in this context
8 | catch (auto foo() -> auto) {}
  |^~~~

Other compilers, clang, or icc accepts this well.

All versions from 6.1 to trunk behave the same.

Thanks,
Haoxin

[Bug c++/95972] ICE in check_member_template, at cp/decl2.c:570

2020-07-08 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95972

--- Comment #2 from Haoxin Tu  ---
Update a new case.

Input:
int a() { [] ( auto class {int b()}}

Output:
: In function 'int a()':
:1:27: error: types may not be defined in parameter types
1 | int a() { [] ( auto class {int b()}}
  |   ^
:1:34: internal compiler error: in check_member_template, at
cp/decl2.c:568
1 | int a() { [] ( auto class {int b()}}
  |  ^

[Bug c++/96110] Function declarator with a trailing return type "auto" should be allowed in try-catch block

2020-07-08 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96110

--- Comment #5 from Haoxin Tu  ---
(In reply to Jonathan Wakely from comment #2)
> This isn't specific to catch handlers, other compilers accept that nonsense
> function declaration in various contexts, and GCC rejects them all:

Thanks for your clarifying, this is a misunderstanding of mine.

[Bug c++/95972] ICE in check_member_template, at cp/decl2.c:570

2020-07-08 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95972

--- Comment #4 from Haoxin Tu  ---
(In reply to Marek Polacek from comment #3)

> You can still use creduce (I do), but it's good to try adding missing
> parens/braces and similar to make the code more sensible.

Yes, you are right. Thanks for you advise, and I am doing this like what you
said.

[Bug c++/96116] New: GCC accepts "enum struct/class" in reference to enumeration

2020-07-08 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96116

Bug ID: 96116
   Summary: GCC accepts "enum struct/class" in reference to
enumeration
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: accepts-invalid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

Hi,all.

This code, might be an invalid code, but GCC accepts it.

$cat test.cc
using alias1 = enum struct E1;
using alias2 = enum class E2;

While in clang:
$clang++ test.cc
test.cc:1:21: error: reference to enumeration must use 'enum' not 'enum struct'
[-Welaborated-enum-class]
using alias1 = enum struct E1;
^~~
test.cc:2:21: error: reference to enumeration must use 'enum' not 'enum class'
[-Welaborated-enum-class]
using alias2 = enum class E2;
^~
2 errors generated.


Here is a related bug report in llvm:
https://bugs.llvm.org/show_bug.cgi?id=46603

They suggested that ""enum class" can only be used when defining an enumeration
or as part of a standalone forward declaration"

Versions from 6.1 to trunk behave the same. So is this an invalid code for GCC?

Thanks,
Haoxin

[Bug c++/96118] New: GCC accepts invalid combination of two type specifiers

2020-07-08 Thread haoxintu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96118

Bug ID: 96118
   Summary: GCC accepts invalid combination of two type specifiers
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Keywords: accepts-invalid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: haoxintu at gmail dot com
  Target Milestone: ---

Hi, all.

This code, combines a typedef specifier and a normal type specifier, might be
an invalid code. 

$cat test.cc
typedef long typedef_long;
typedef_long long var = 10;

GCC accept this well.

While in clang:
error: 'long type-name' is invalid

in icc:
error: invalid combination of type specifiers

in msvc:
error C2628: 'typedef_long' followed by 'long' is illegal (did you forget a
';'?)

All versions from GCC 4.0 to trunk behave the same.

Thanks,
Haoxin

  1   2   >