[Bug c/115644] [gcc][trunk] ICE if redeclare a variable with different type

2024-06-25 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115644

--- Comment #1 from wierton <141242068 at smail dot nju.edu.cn> ---
This crash seems to be the same cause: https://gcc.godbolt.org/z/6br3xoaKG

The testing program:
```
void f()
{
  int p;
  unsigned v;
  v = (~0u) >> p;
  int p[1] = p;
}
```

[Bug c/115646] New: [gcc][trunk] ICE in gen_conditions_for_pow_int_base, at tree-call-cdce.cc:587

2024-06-25 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115646

Bug ID: 115646
   Summary: [gcc][trunk] ICE in gen_conditions_for_pow_int_base,
at tree-call-cdce.cc:587
   Product: gcc
   Version: 15.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler explorer: https://gcc.godbolt.org/z/rax1zezbc

The testing program:
```
#include 

struct S {
unsigned int a : 3, b : 8, c : 21;
};

void foo (struct S *p)
{
  pow(p->c, 42);
}
```

When compiling it using gcc-trunk with option `-O2`, gcc crashes:
```
during GIMPLE pass: cdce
: In function 'foo':
:7:6: internal compiler error: in gen_conditions_for_pow_int_base, at
tree-call-cdce.cc:587
7 | void foo (struct S *p)
  |  ^~~
0x23be10c internal_error(char const*, ...)
???:0
0x986355 fancy_abort(char const*, int, char const*)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c/115644] New: [gcc][trunk] ICE if redeclare a variable with different type

2024-06-25 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115644

Bug ID: 115644
   Summary: [gcc][trunk] ICE if redeclare a variable with
different type
   Product: gcc
   Version: 15.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Quick verification link: https://gcc.godbolt.org/z/fdY8KqhK6

The testing program:
```
void foo ()
{
  int p[5];
  int v = *p;
  int *p = 0;
}
```

Compiling this program using gcc-trunk will trigger crash, and dump stacks as
follows:
```
0x23be10c internal_error(char const*, ...)
???:0
0x8948df tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
???:0
0xd120d0 gimple_fold_indirect_ref(tree_node*)
???:0
0xd5b8f7 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xd5f06a gimplify_stmt(tree_node**, gimple**)
???:0
0xd5c472 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xd5f06a gimplify_stmt(tree_node**, gimple**)
???:0
0xd5c75b gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xd5f06a gimplify_stmt(tree_node**, gimple**)
???:0
0xd5bf2a gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xd651b3 gimplify_body(tree_node*, bool)
???:0
0xd655f9 gimplify_function_tree(tree_node*)
???:0
0xb87377 cgraph_node::analyze()
???:0
0xb8a6d1 symbol_table::finalize_compilation_unit()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c/115642] New: [gcc][trunk] internal compiler error: tree check: expected class 'type', have 'exceptional' (error_mark) in c_expr_sizeof_expr

2024-06-25 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115642

Bug ID: 115642
   Summary: [gcc][trunk] internal compiler error: tree check:
expected class 'type', have 'exceptional' (error_mark)
in c_expr_sizeof_expr
   Product: gcc
   Version: 15.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler explorer: https://gcc.godbolt.org/z/EWcfsT9hW

This crash involve gcc-trunk, no additional options are required.

The crash triggering program:
```
void f (int N) {
  int a[2][N]; 
  sizeof ((int [2][N])a);
}
```

The stack dump:
```
:3:3: internal compiler error: tree check: expected class 'type', have
'exceptional' (error_mark) in c_expr_sizeof_expr, at c/c-typeck.cc:3390
3 |   sizeof ((int [2][N])a);
  |   ^~
0x23be10c internal_error(char const*, ...)
???:0
0x8948df tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
???:0
0xa3bf1b c_parse_file()
???:0
0xab5959 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c/115641] New: GCC crashes on function has attribute `__attribute__((const))`

2024-06-25 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115641

Bug ID: 115641
   Summary: GCC crashes on function has attribute
`__attribute__((const))`
   Product: gcc
   Version: 15.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/79oo9rsxj

When compiling this with `gcc-trunk -O2`, gcc crashes.
This only occurs in trunk version, older versions like gcc-{12,13,14} are
tested to be normal.
```
#include 

typedef struct {
  char hours, day, month;
  short year;
} T;

T g (void) {
  T now;
  now.hours = 1;
  now.day = 2;
  now.month = 3;
  now.year = 4;
  return now;
}

__attribute__((const)) T f (void)
{
  T virk = g ();
  return virk;
}

int main ()
{
  if (f ().hours != 1 || f ().day != 2 || f ().month != 3 || f ().year != 4)
abort ();
  return 0;
}
```

[Bug c/114597] [GCC-14] Miscompilation of pointer assignment with inline assembly

2024-04-05 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114597

--- Comment #5 from wierton <141242068 at smail dot nju.edu.cn> ---
(In reply to Xi Ruoyao from comment #4)
> I believe the second form is still incorrect and it just works by luck.  To
> ensure it work you have to do:
> 
> asm("mov %1,%0":"=r"(n.p):"r"(n.p));
> 
> Or
> 
> asm("":"+r"(n.p));
> 
> Not so sure about the third form.

Thank you for your explanation, it helps me a lot :).

[Bug c/114598] [GCC-14] Miscompilation of `#pragma omp parallel for`

2024-04-04 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114598

wierton <141242068 at smail dot nju.edu.cn> changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #1 from wierton <141242068 at smail dot nju.edu.cn> ---
Seems invalid, as `j` is not private within the openmp region

[Bug c/114598] New: [GCC-14] Miscompilation of `#pragma omp parallel for`

2024-04-04 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114598

Bug ID: 114598
   Summary: [GCC-14] Miscompilation of `#pragma omp parallel for`
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/MPzrsv17v

```
#include 

#define N 2000
int a[N][N];

int main (void)
{
  int i = 0, j = 0;
  for (i = 0; i < N; i++)
#pragma omp parallel for
for (j = 0; j < N; j++)
  a[i][j] = i + j;
  return 0;
}
```

This program will crash if compiled with `gcc-14 -fopenmp-simd`, while clang
can correctly compile it.

[Bug c/114597] [GCC-14] Miscompilation of pointer assignment with inline assembly

2024-04-04 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114597

--- Comment #3 from wierton <141242068 at smail dot nju.edu.cn> ---
Thanks a lot, I have checked it out.

I'm still somewhat confused. Does the difference in compilation stem from GCC
interpreting "=m" and "=r" differently, leading it to assume that once "n.p" is
declared as an output operand without matched input declaration (eg. "=m"
expects "m", "=r" expects "r"), its value is expected to change?

```
asm("":"=m"(n.p):"r"(n.p)); // n.p is expected to change
asm("":"=r"(n.p):"r"(n.p)); // n.p can retain its value
asm("":"=m"(n.p):"m"(n.p)); // n.p can retain its value
```

Thanks in advance for any further explanation you can provide.

[Bug c/114597] New: [GCC-14] Miscompilation of pointer assignment with inline assembly

2024-04-04 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114597

Bug ID: 114597
   Summary: [GCC-14] Miscompilation of pointer assignment with
inline assembly
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/Pn4EG3zzj

```
struct node { void *p; } n;
struct head { struct node *n; } h;

int main () {
  n.p = 
  asm("":"=m"(n.p):"r"(n.p));
  if (n.p != )
__builtin_abort();
  return 0;
}
```

I sanitized this program with all sanitizers I know, they report nothing.
When compile this program with `gcc-14 -O2`, the compiled program aborts, while
`-O0` normally exits.

Any potential undefined behavior:
1. strict aliasing, I added option `-fno-strict-aliasing` to `-O2`, the abort
still exists.
2. If there is some other undefined behavior unknown to me cause this
compilation inconsistency, please let me know.

Regarding the inline assembly, it's important to note that even though `n.p` is
specified as an output operand with `=m`, this doesn't necessarily imply that
`n.p` will be altered. The inline assembly might simply reassign the original
value to `n.p`, leaving it effectively unchanged.

[Bug c/114205] New: Miscompilation: the use of __builtin_object_size cause asan failure.

2024-03-01 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114205

Bug ID: 114205
   Summary: Miscompilation: the use of __builtin_object_size cause
asan failure.
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

This program:
```
#include 

static char a[40];

int main() {
  if (__builtin_object_size([0] + 1, 1) == (size_t)-1)
__builtin_abort();
  return 0;
}
```

When compiled with `gcc -fsanitize=address`, the result binary reports error.
But if change the branch compare operator from "==" into "!=", then result
binary compiled from `gcc -fsanitize=address` reports nothing.

Error with "==", can be verified on https://gcc.godbolt.org/z/vWxWhYoMT
Normal with "!=", can be verified on https://gcc.godbolt.org/z/sb4bGs76f

[Bug c/114203] New: Miscompilation: A possible miscompilation in GCC 13 and 14 with option -Os

2024-03-01 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114203

Bug ID: 114203
   Summary: Miscompilation: A possible miscompilation in GCC 13
and 14 with option -Os
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

The reproduce link: https://gcc.godbolt.org/z/T48jbo5e7

The reproducer (diff: `gcc-14 -O0` and `gcc-14 -Os`):
```
int foo (unsigned char b) {
int c = 0;

while (b) {
b >>= 1;
c++;
}

return c;
}

int main()
{
  if (foo(0) != 0)
__builtin_abort ();
  return 0;
}
```

I have sanitized this program using ubsan and asan, ubsan and asans outputs
nothing, so I think this is likely a miscompilation bug.

[Bug c/112512] New: GCC: 14: internal compiler error: in lra_split_hard_reg_for, at lra-assigns.cc:1861

2023-11-13 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112512

Bug ID: 112512
   Summary: GCC: 14: internal compiler error: in
lra_split_hard_reg_for, at lra-assigns.cc:1861
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/jG4PfK845

When compiling this program with `gcc-14 -Og`, gcc ICEs:
```
extern int f();

int f1(char *s) {
  return f();
}

int f2(char *s) {
  return (f1(s) / f1(s)) && f1(s);
}

register int v asm("%rax"); // both rax and eax are able to trigger the crash

char *f3(char *s) {}
```

The output of crash log:
```
:11:14: warning: call-clobbered register used for global register
variable
   11 | register int v asm("%rax");
  |  ^
: In function 'f2':
:9:1: error: unable to find a register to spill
9 | }
  | ^
:9:1: error: this is the insn:
(insn 14 40 37 2 (parallel [
(set (reg:SI 107 [orig:98 _1 ] [98])
(div:SI (reg:SI 107 [orig:98 _1 ] [98])
(reg:SI 0 ax)))
(set (reg:SI 103)
(mod:SI (reg:SI 107 [orig:98 _1 ] [98])
(reg:SI 0 ax)))
(clobber (reg:CC 17 flags))
]) "":8:17 discrim 2 539 {*divmodsi4}
 (expr_list:REG_UNUSED (reg:SI 103)
(expr_list:REG_UNUSED (reg:CC 17 flags)
(nil
during RTL pass: reload
:9:1: internal compiler error: in lra_split_hard_reg_for, at
lra-assigns.cc:1861
0x238b06e internal_error(char const*, ...)
???:0
0xa1125c fancy_abort(char const*, int, char const*)
???:0
0x827c80 _fatal_insn(char const*, rtx_def const*, char const*, int, char
const*)
???:0
0xf202e5 lra_split_hard_reg_for()
???:0
0xf1a459 lra(_IO_FILE*)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1
```

[Bug c/112511] New: GCC: 14: internal compiler error: in type_contains_placeholder_1, at tree.cc:4243

2023-11-13 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112511

Bug ID: 112511
   Summary: GCC: 14: internal compiler error: in
type_contains_placeholder_1, at tree.cc:4243
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/E457vrbGM

When compiling this program with `gcc-14 -O2`, gcc ICEs:
```
struct T {
  _BitInt(22) a;
};

void g(struct T v) { }

void f() {
  struct T v;
  g(v);
}
```

The crash output pasted from Compiler Explorer:
```
during GIMPLE pass: esra
: In function 'f':
:10:1: internal compiler error: in type_contains_placeholder_1, at
tree.cc:4243
   10 | }
  | ^
0x238b06e internal_error(char const*, ...)
???:0
0xa1125c fancy_abort(char const*, int, char const*)
???:0
0x14596c1 type_contains_placeholder_p(tree_node*)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1
```

[Bug c/112509] New: GCC: 14: internal compiler error: in verify_range, at value-range.cc:1132

2023-11-13 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112509

Bug ID: 112509
   Summary: GCC: 14: internal compiler error: in verify_range, at
value-range.cc:1132
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/151vEnafj

When compiling this program with `gcc-14 -O2 -fno-tree-vrp -fno-tree-fre
-fno-tree-forwprop`, gcc crashes:

```
struct S {
  unsigned j : 3;
};
int k, l, m_1 = {0};
void f(int l, struct S x) {
  unsigned int k_1;
  while (m_1 % 8) switch (x.j) {
case 1:
case 3:
case 4:
case 6:
case 2:
case 5: l = m_1;
case 7:
case 0: k_1 = 0;
default: break;
}
}
void foo(struct S x) { f(l, x); }
```

The crash output:
```
during GIMPLE pass: dom
: In function 'f':
:5:6: internal compiler error: in verify_range, at value-range.cc:1132
5 | void f(int l, struct S x) {
  |  ^
0x238b06e internal_error(char const*, ...)
???:0
0xa1125c fancy_abort(char const*, int, char const*)
???:0
0x148ea37 irange::set(tree_node*, generic_wide_int const&,
generic_wide_int const&, value_range_kind)
???:0
0x144ca1f find_case_label_range(gswitch*, irange const*)
???:0
0x139e1ef hybrid_jt_simplifier::simplify(gimple*, gimple*, basic_block_def*,
jt_state*)
???:0
0x139d525 jump_threader::simplify_control_stmt_condition(edge_def*, gimple*)
???:0
0x139db5a jump_threader::thread_through_normal_block(vec*, edge_def*, bitmap_head*)
???:0
0x139fa66 jump_threader::thread_across_edge(edge_def*)
???:0
0x139fc5a jump_threader::thread_outgoing_edges(basic_block_def*)
???:0
0x126f828 dom_opt_dom_walker::after_dom_children(basic_block_def*)
???:0
0x1ed3f2f dom_walker::walk(basic_block_def*)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1
```

[Bug c/112505] New: GCC: 14: internal compiler error: in build_vector_from_val, at tree.cc:2104

2023-11-12 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112505

Bug ID: 112505
   Summary: GCC: 14: internal compiler error: in
build_vector_from_val, at tree.cc:2104
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/nTjnh73xj

The crash triggering program (compile with `gcc-14 -O3`):
```
short int w9;
struct T {
  short a : 14;
  int b;
};
struct T v;
void __attribute__((simd)) zc() {
  w9 *= v.b ? v.a-- < 0 : 0;
}
```

The crash output:
```
during GIMPLE pass: vect
: In function 'zc.simdclone.0':
:7:28: internal compiler error: in build_vector_from_val, at
tree.cc:2104
7 | void __attribute__((simd)) zc() {
  |^~
0x238b15e internal_error(char const*, ...)
???:0
0xa11270 fancy_abort(char const*, int, char const*)
???:0
0x13ee023 vectorizable_induction(_loop_vec_info*, _stmt_vec_info*, gimple**,
_slp_tree*, vec*)
???:0
0x2115bf8 vect_transform_stmt(vec_info*, _stmt_vec_info*,
gimple_stmt_iterator*, _slp_tree*, _slp_instance*)
???:0
0x13fedc0 vect_transform_loop(_loop_vec_info*, gimple*)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1
```

[Bug c/112504] New: gcc: 14: internal compiler error: in operand_equal_p, at fold-const.cc:3313

2023-11-12 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112504

Bug ID: 112504
   Summary: gcc: 14: internal compiler error: in operand_equal_p,
at fold-const.cc:3313
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/YdETsKzeb

When compiling this program with `gcc-14 -O0`, gcc crashes:
```
struct s {
  char c[1];
};
extern struct s foo(void);
void bar(void) {
  foo().c == foo().c;
}
```

The crash output:
```
: In function 'bar':
:6:3: internal compiler error: in operand_equal_p, at
fold-const.cc:3313
6 |   foo().c == foo().c;
  |   ^~~
0x238b15e internal_error(char const*, ...)
???:0
0xa11270 fancy_abort(char const*, int, char const*)
???:0
0xd0bd67 operand_compare::operand_equal_p(tree_node const*, tree_node const*,
unsigned int)
???:0
0xd0b6e4 operand_compare::operand_equal_p(tree_node const*, tree_node const*,
unsigned int)
???:0
0xd25837 fold_binary_loc(unsigned int, tree_code, tree_node*, tree_node*,
tree_node*)
???:0
0xd45c84 fold(tree_node*)
???:0
0xac0aef c_fully_fold(tree_node*, bool, bool*, bool)
???:0
0xa574e3 c_process_expr_stmt(unsigned int, tree_node*)
???:0
0xa57711 c_finish_expr_stmt(unsigned int, tree_node*)
???:0
0xabd40d c_parse_file()
???:0
0xb30909 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1
```

[Bug c/112503] New: GCC: 14: internal compiler error: Segmentation fault at gsi_start_edge(edge_def*)

2023-11-12 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112503

Bug ID: 112503
   Summary: GCC: 14: internal compiler error: Segmentation fault
at gsi_start_edge(edge_def*)
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/erEvbYYKc

When compiling this program with `gcc-14 -O1`, gcc crashes:
```
struct T { int x; };
int foo(void) {
  struct T v;
  asm goto("" : "+r"(v.x) : : : lab);
  return 0;
lab:
  return -5;
}
```

The crash output:
```
during GIMPLE pass: esra
: In function 'foo':
:8:1: internal compiler error: Segmentation fault
8 | }
  | ^
0x238b15e internal_error(char const*, ...)
???:0
0xd7cb34 gsi_start_edge(edge_def*)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1
```

[Bug c/112502] New: GCC: 14: internal compiler error: in get_predictor_value, at predict.cc:2695

2023-11-12 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112502

Bug ID: 112502
   Summary: GCC: 14: internal compiler error: in
get_predictor_value, at predict.cc:2695
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/WP94TWqj5

When compiling this program with `gcc-14 -O1`, gcc crashes:
```
int global;

void foo(int a, short b) {
  if (__builtin_expect_with_probability(a, 1, -2.0f) >
  __builtin_expect_with_probability(b, 0, 0.8f))
global++;
}
```

Based on the diagnostic error messages, the cause of the crash appears to be
the invalid argument `-2.0f` passed into the
`__builtin_expect_with_probability` function. But after removing the `if`, as
this program, the crash disappears:
```
int global;

void foo(int a, short b) {
  __builtin_expect_with_probability(a, 1, -2.0f) >
  __builtin_expect_with_probability(b, 0, 0.8f);
  global++;
}
```

The crash output:
```
: In function 'foo':
:4:7: error: probability '-2.0e+0' is outside the range [0.0, 1.0]
4 |   if (__builtin_expect_with_probability(a, 1, -2.0f) >
  |   ^~
during GIMPLE pass: profile_estimate
:7:1: internal compiler error: in get_predictor_value, at
predict.cc:2695
7 | }
  | ^
0x238b15e internal_error(char const*, ...)
???:0
0xa11270 fancy_abort(char const*, int, char const*)
???:0
0x1019629 tree_estimate_probability(bool)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1
```

[Bug c/112501] New: GCC: 14: internal compiler error: in extract_insn, at recog.cc:2804

2023-11-12 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112501

Bug ID: 112501
   Summary: GCC: 14: internal compiler error: in extract_insn, at
recog.cc:2804
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/65TGaK86r

When compiling this program with `gcc-14 -O1`, gcc crashes:
```
short b;

int main() {
  if (b + 2) __builtin_abort();
  if (__builtin_speculation_safe_value(b) != 2)
__builtin_abort();
  return 0;
}
```

A interesting finding: after replacing `b + 2` by `b` in the first if-stmt's
condition expr, this crash disappears, though it seems the root cause ought to
be the second if-stmt.

The crash output:
```
: In function 'main':
:8:1: error: unrecognizable insn:
8 | }
  | ^
(insn 15 14 16 5 (set (reg:HI 99 [ _4 ])
(const_int 65534 [0xfffe])) "":5:7 -1
 (nil))
during RTL pass: vregs
:8:1: internal compiler error: in extract_insn, at recog.cc:2804
0x238b15e internal_error(char const*, ...)
???:0
0xa11270 fancy_abort(char const*, int, char const*)
???:0
0x827c80 _fatal_insn(char const*, rtx_def const*, char const*, int, char
const*)
???:0
0x827ca2 _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1
```

[Bug c/112500] New: GCC: 14: internal compiler error: in expand_asm_stmt, at cfgexpand.cc:3419

2023-11-12 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112500

Bug ID: 112500
   Summary: GCC: 14: internal compiler error: in expand_asm_stmt,
at cfgexpand.cc:3419
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/PbTj4Gq3r

When compiling this program with `gcc-14 -O0`, gcc crashes:
```
void f(char *a, unsigned int l) {
  asm volatile("" ::"m"((char (*)[l])a--));
}
```

The crash output:
```
during RTL pass: expand
: In function 'f':
:2:3: internal compiler error: in expand_asm_stmt, at cfgexpand.cc:3419
2 |   asm volatile("" ::"m"((char (*)[l])a--));
  |   ^~~
0x238b15e internal_error(char const*, ...)
???:0
0xa11270 fancy_abort(char const*, int, char const*)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1
```

[Bug c/112499] New: GCC: 14: internal compiler error: output_operand: invalid expression as operand

2023-11-12 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112499

Bug ID: 112499
   Summary: GCC: 14: internal compiler error: output_operand:
invalid expression as operand
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/MdacfWqhr

When attempting to compile this program with `gcc-14 -O1`, gcc crashes:
```
#include 

int f(void) {
  static uintptr_t a = ((char *)& - (char *)&) +
   ((char *)& - (char *)&);
l1:
l2:
l3:
  return a;
}
```

If removing the qualifier `static`, then this crash disappears.

The crash output:
```
:10:1: internal compiler error: output_operand: invalid expression as
operand
   10 | }
  | ^
0x238b15e internal_error(char const*, ...)
???:0
0xd01147 output_operand_lossage(char const*, ...)
???:0
0xd01c71 output_addr_const(_IO_FILE*, rtx_def*)
???:0
0xd01a53 output_addr_const(_IO_FILE*, rtx_def*)
???:0
0xd01ae5 output_addr_const(_IO_FILE*, rtx_def*)
???:0
0x14cec92 assemble_integer_with_op(char const*, rtx_def*)
???:0
0x14cecf1 default_assemble_integer(rtx_def*, unsigned int, int)
???:0
0x14ced7f assemble_integer(rtx_def*, unsigned int, unsigned int, int)
???:0
0x14e1cae assemble_variable(tree_node*, int, int, int)
???:0
0x14e62ae symbol_table::output_variables()
???:0
0xc027bb symbol_table::finalize_compilation_unit()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1
```

[Bug c/112496] New: GCC: 14: internal compiler error: in vectorizable_nonlinear_induction, at tree-vect-loop.cc:9573

2023-11-12 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112496

Bug ID: 112496
   Summary: GCC: 14: internal compiler error: in
vectorizable_nonlinear_induction, at
tree-vect-loop.cc:9573
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/7aq3hjbjK

When compile this program with `gcc-14 -O2`, gcc ICEs:
```
struct T { int x : 24; } v;
void f1(int x) {
  while (v.x - ((v.x <<= 1) - v.x)) ;
}
```

The crash output:
```
during GIMPLE pass: vect
: In function 'f1':
:2:6: internal compiler error: in vectorizable_nonlinear_induction, at
tree-vect-loop.cc:9573
2 | void f1(int x) {
  |  ^~
0x238b15e internal_error(char const*, ...)
???:0
0xa11270 fancy_abort(char const*, int, char const*)
???:0
0x13ec547 vectorizable_induction(_loop_vec_info*, _stmt_vec_info*, gimple**,
_slp_tree*, vec*)
???:0
0x13fe290 vect_analyze_loop(loop*, vec_info_shared*)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1
```

[Bug c/112495] GCC: 14: internal compiler error: verify_gimple failed

2023-11-12 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112495

--- Comment #1 from wierton <141242068 at smail dot nju.edu.cn> ---
Correction: It should be -O3.

[Bug c/112495] New: GCC: 14: internal compiler error: verify_gimple failed

2023-11-12 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112495

Bug ID: 112495
   Summary: GCC: 14: internal compiler error: verify_gimple failed
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/7sM17Pfbb

When compile this program with `gcc-14 -O1`, gcc ICEs:
```
typedef struct { int v; } T1;
typedef struct { T1 v[32]; } T2;

T1 s;
T1 f1() { return s; }

void f2(__seg_gs T2 *p, int n) {
  for (int i = 0; i < n; ++i) p->v[i] = f1();
}
```

Interestingly, if replacing the call of `f1`() by `s` (manual inline f1), this
crash disappears.

The crash output:
```
: In function 'f2':
:7:6: error: mismatching comparison operand types
7 | void f2(__seg_gs T2 *p, int n) {
  |  ^~
 struct T2 *
struct T1 *
_22 = p_6(D) >= _21;
:7:6: error: mismatching comparison operand types
 struct T2 *
struct T1 *
_27 = _26 <= 
during GIMPLE pass: vect
:7:6: internal compiler error: verify_gimple failed
0x238b15e internal_error(char const*, ...)
???:0
0x117b6c9 verify_gimple_in_cfg(function*, bool, bool)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1
```

[Bug c/112494] New: GCC: 14: internal compiler error: in ix86_cc_mode, at config/i386/i386.cc:16477

2023-11-12 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112494

Bug ID: 112494
   Summary: GCC: 14: internal compiler error: in ix86_cc_mode, at
config/i386/i386.cc:16477
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/cPPxenx7q

When compile this program with `-Og  -fno-tree-copy-prop -fno-tree-fre
-fno-tree-ccp -fno-tree-forwprop`, gcc crashes:
```
#include 

#ifdef __x86_64__
#  define EFLAGS_TYPE unsigned long long int
#else
#  define EFLAGS_TYPE unsigned int
#endif

int main() {
  EFLAGS_TYPE flags = 0xD7;
  __writeeflags(0xD7);
  flags && !__readeflags();
  if ((flags && (!__readeflags())) != 0xD7);
  return 0;
}
```

There are some intriguing observations about this crash.
1. Removing the `flags &&` portion at the point of the first __readeflags()
call eliminates the crash, even though it appears that `flags &&` has no
effect.
2. Removing the `!= 0xD7` portion at the point of the second __readeflags()
call also eliminates the crash.


The crash output:
```
during RTL pass: combine
: In function 'main':
:15:1: internal compiler error: in ix86_cc_mode, at
config/i386/i386.cc:16477
   15 | }
  | ^
0x238b15e internal_error(char const*, ...)
???:0
0xa11270 fancy_abort(char const*, int, char const*)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1
```

[Bug c/112493] New: GCC: 14: internal compiler error: in verify_sra_access_forest, at tree-sra.cc:2421

2023-11-12 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112493

Bug ID: 112493
   Summary: GCC: 14: internal compiler error: in
verify_sra_access_forest, at tree-sra.cc:2421
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/971ccPba8

When tries to compile this program with `gcc-14 -O1`, gcc throws internal
compiler error:
```
#define BIG_ENDIAN \
  __attribute__((scalar_storage_order("big-endian")))

typedef struct {
  union {
char addr8[16];
  } u;
} ip6_addr_t;

typedef struct {
  char is_v4;
  union {
int addr;
ip6_addr_t addr6;
  } u;
} net_addr_t;

typedef struct {
  union {
char addr8[16];
  } u;
} be_ip6_addr_t;

typedef struct {
  char is_v4;
  union {
be_ip6_addr_t addr6;
char addr;
  } BIG_ENDIAN u;
} BIG_ENDIAN be_net_addr_t;

struct T {
  const net_addr_t ip;
  be_ip6_addr_t rc;
} v;

be_ip6_addr_t be_ip6_addr(const ip6_addr_t ip6) {
  return v.rc;
}

be_net_addr_t be_net_addr(const net_addr_t ip) {
  be_net_addr_t rc;
  if (v.ip.is_v4) {
rc.u.addr = v.ip.u.addr;
  } else {
rc.u.addr6 = be_ip6_addr(v.ip.u.addr6);
  }
  return rc;
}
```

The crash output:
```
:27:19: warning: type punning toggles scalar storage order
[-Wscalar-storage-order]
   27 | be_ip6_addr_t addr6;
  |   ^
during GIMPLE pass: sra
: In function 'be_net_addr':
:41:15: internal compiler error: in verify_sra_access_forest, at
tree-sra.cc:2421
   41 | be_net_addr_t be_net_addr(const net_addr_t ip) {
  |   ^~~
0x238b15e internal_error(char const*, ...)
???:0
0xa11270 fancy_abort(char const*, int, char const*)
???:0
0x1226f82 verify_all_sra_access_forests()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1
```

[Bug c/112489] New: GCC: 14: internal compiler error: in check_loop_closed_ssa_def, at tree-ssa-loop-manip.cc:647

2023-11-12 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112489

Bug ID: 112489
   Summary: GCC: 14: internal compiler error: in
check_loop_closed_ssa_def, at
tree-ssa-loop-manip.cc:647
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/89rPW14fv

When compile this program with `gcc-14 -O3 -fno-tree-dominator-opts`, gcc-14
crashes.
```
#define M 3000
static double a[M][M], b[M][M], c[M][M];

int N;
struct T {
  int k;
  double a[M][M];
} v;
void f() {
  for (int i = 0; i < N; i) {
for (int j = 0; j < N; j++) {
  for (v.k = j; +v.k < N; v.k++) {
c[j][v.k] += v.a[i][j] * b[i][v.k] +
 b[i][-j] * v.a[i - i][+v.k];
c[j][v.k] += v.a[i][j] * b[i][v.k] +
 b[i][-j] * v.a[i - i][-v.k];
  }
}
  }
}
```

The crash output:
```
during GIMPLE pass: ch_vect
: In function 'f':
:9:6: internal compiler error: in check_loop_closed_ssa_def, at
tree-ssa-loop-manip.cc:647
9 | void f() {
  |  ^
0x238b15e internal_error(char const*, ...)
???:0
0xa11270 fancy_abort(char const*, int, char const*)
???:0
0x12c17de verify_loop_closed_ssa(bool, loop*)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1
```

[Bug c/112488] New: GCC: 14: internal compiler error: in make_ssa_name_fn, at tree-ssanames.cc:354

2023-11-12 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112488

Bug ID: 112488
   Summary: GCC: 14: internal compiler error: in make_ssa_name_fn,
at tree-ssanames.cc:354
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler explorer: https://gcc.godbolt.org/z/h9aen36q7

When compile this program with `gcc-14 -O1`, gcc ICEs:
```
extern void abort(void);

int test(int *n) {
  struct T { char a[*n], b[*n]; };
  return sizeof(struct T) - sizeof(struct T);
}

void f1(int *p) {
  if (test(p)) abort();
}
```

The crash output:
```
during IPA pass: inline
In function 'test':
cc1: internal compiler error: in make_ssa_name_fn, at tree-ssanames.cc:354
0x238b15e internal_error(char const*, ...)
???:0
0xa11270 fancy_abort(char const*, int, char const*)
???:0
0x11bd6ff copy_tree_body_r(tree_node**, int*, void*)
???:0
0x147a55c walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set >*))
???:0
0x147a8c4 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set >*))
???:0
0x147a8c4 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set >*))
???:0
0x11b8ac9 remap_type(tree_node*, copy_body_data*)
???:0
0x11b8bdf remap_decl(tree_node*, copy_body_data*)
???:0
0x11c5b59 tree_function_versioning(tree_node*, tree_node*,
vec*, ipa_param_adjustments*, bool,
bitmap_head*, basic_block_def*)
???:0
0xe698db inline_transform(cgraph_node*)
???:0
0xfec7fb execute_all_ipa_transforms(bool)
???:0
0xbfe2d9 cgraph_node::expand()
???:0
0xc027bb symbol_table::finalize_compilation_unit()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug ipa/112486] GCC: 14: hangs with always_inline

2023-11-12 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112486

wierton <141242068 at smail dot nju.edu.cn> changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #2 from wierton <141242068 at smail dot nju.edu.cn> ---
Thank you for your reply! I will close this issue.

[Bug c/112487] New: GCC: 14: internal compiler error: in setup_one_parameter, at tree-inline.cc:3565

2023-11-12 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112487

Bug ID: 112487
   Summary: GCC: 14: internal compiler error: in
setup_one_parameter, at tree-inline.cc:3565
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler explorer: https://gcc.godbolt.org/z/fjErPvrvP

When compile this program with `gcc-14 -O1`, gcc crashes:
```
struct A { char i; };
struct B {
  struct C *p;
  struct A *q;
};
struct C { struct B a[1]; };
struct T { struct U *ptr; };

volatile struct T v;
void f1(volatile struct T v) { f2(v); }
void f2(volatile struct T *const v) { }
void bar() {
  struct U *ptr;
  f1(v);
}
```

The crash output pasted from compiler explorer:
```
: In function 'f1':
:10:32: warning: implicit declaration of function 'f2'; did you mean
'f1'? [-Wimplicit-function-declaration]
   10 | void f1(volatile struct T v) { f2(v); }
  |^~
  |f1
: At top level:
:11:6: warning: conflicting types for 'f2'; have 'void(volatile struct
T * const)'
   11 | void f2(volatile struct T *const v) { }
  |  ^~
:10:32: note: previous implicit declaration of 'f2' with type
'void(volatile struct T * const)'
   10 | void f1(volatile struct T v) { f2(v); }
  |^~
during IPA pass: inline
: In function 'f1':
:10:32: internal compiler error: in setup_one_parameter, at
tree-inline.cc:3565
   10 | void f1(volatile struct T v) { f2(v); }
  |^
0x238b15e internal_error(char const*, ...)
???:0
0xa11270 fancy_abort(char const*, int, char const*)
???:0
0x11c5051 optimize_inline_calls(tree_node*)
???:0
0xe69aeb inline_transform(cgraph_node*)
???:0
0xfec7fb execute_all_ipa_transforms(bool)
???:0
0xbfe2d9 cgraph_node::expand()
???:0
0xc027bb symbol_table::finalize_compilation_unit()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c/112486] New: GCC: 14: hangs with always_inline

2023-11-12 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112486

Bug ID: 112486
   Summary: GCC: 14: hangs with always_inline
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/3n34j7fPT

When try to compile this program with `gcc-14 -O2`:
```
unsigned long flg = 0;

int n_1 = {0};
__attribute__((always_inline))
long sub(unsigned long n) {
  int a, b;
  if (n_1 >= 2) {
if (n_1 % 2 == 0) {
  a = sub(n_1 / 2);
  { return (a & 2 >> sub(n_1 / 2 - 1)) * a; };
} else {
  a = sub(n_1 / 2 + 1);
  b = sub(n_1 / 2);
  return (sub(n_1 / 2)) * a + b * b;
}
  } else
return (long)n_1;
}

int main(void) {
  if (sub(30) != 832040L) flg |= 0x100L;
  if (flg) abort();
  exit(0);
}
```

GCC 14 hangs with a lot of output, according to the output, it seems GCC tries
to recursively expand all invocation to `sub`.

The partial output pasted from compiler explorer:
```
In function 'sub',
inlined from 'sub' at :13:11,
inlined from 'sub' at :12:11,
inlined from 'sub' at :13:11,
inlined from 'sub' at :10:26,
inlined from 'sub' at :10:26,
inlined from 'sub' at :10:26,
inlined from 'sub' at :10:26,
inlined from 'sub' at :9:11,
inlined from 'sub' at :9:11,
inlined from 'sub' at :12:11,
inlined from 'sub' at :12:11,
inlined from 'main' at :21:7:
:5:6: error: inlining failed in call to 'always_inline' 'sub':
recursive inlining
5 | long sub(unsigned long n) {
  |  ^~~
:10:26: note: called from here
   10 |   { return (a & 2 >> sub(n_1 / 2 - 1)) * a; };
  |  ^~~~
:5:6: error: inlining failed in call to 'always_inline' 'sub':
recursive inlining
5 | long sub(unsigned long n) {
  |  ^~~
:9:11: note: called from here
9 |   a = sub(n_1 / 2);
  |   ^~~~
:5:6: error: inlining failed in call to 'always_inline' 'sub':
recursive inlining
5 | long sub(unsigned long n) {
  |  ^~~
:13:11: note: called from here
   13 |   b = sub(n_1 / 2);
  |   ^~~~
:5:6: error: inlining failed in call to 'always_inline' 'sub':
recursive inlining
5 | long sub(unsigned long n) {
  |  ^~~
:12:11: note: called from here
   12 |   a = sub(n_1 / 2 + 1);
  |   ^~~~
In function 'sub',
inlined from 'sub' at :13:11,
inlined from 'sub' at :13:11,
inlined from 'sub' at :10:26,
inlined from 'sub'
[Truncated]
Compiler returned: 143
```

[Bug c/111922] GCC: internal compiler error: in decompose, at wide-int.h:1049

2023-10-22 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111922

--- Comment #1 from wierton <141242068 at smail dot nju.edu.cn> ---
Compiler Explorer: https://gcc.godbolt.org/z/EoPGKa9r8

The link above seems broken.

[Bug c/111922] New: GCC: internal compiler error: in decompose, at wide-int.h:1049

2023-10-22 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111922

Bug ID: 111922
   Summary: GCC: internal compiler error: in decompose, at
wide-int.h:1049
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer:
[https://gcc.godbolt.org/z/EoPGKa9r8](https://gcc.godbolt.org/z/EoPGKa9r8)

The code that triggers the crash is somewhat extensive. I've attempted to
minimize it, but the underlying cause seems to be complex. Here's the code:

```c
void f2(void);
struct T1 { int w; };
struct T2 { struct T1 *wi; int a; } v;

static int f1(dpy, wi)
struct T3 *dpy;
struct T1 *wi;
{
  (v.a = v.wi->w) || (v.a = v.wi->w);
  f2();
}

static void f3(int wi, int c) {
  int b = f1(0, ~wi);
  fn4(0, 0, v.a);
}

void f5() { f3(0, 0); }
```

Compiling this program with `-O2 -fno-tree-fre` causes GCC to crash.

Some interesting observations about this crash:
1. The crash only occurs when the function `f1` is declared using the old-style
function declaration. If it is converted to the modern style, the crash doesn't
occur.
2. If any statement in the code is commented out, even if it's just half of the
logic or expression inside `f1`, the crash disappears.

The full stack dump:
```
: In function 'f3':
:15:3: warning: implicit declaration of function 'fn4'
[-Wimplicit-function-declaration]
   15 |   fn4(0, 0, v.a);
  |   ^~~
during IPA pass: cp
: At top level:
:18:1: internal compiler error: in decompose, at wide-int.h:1049
   18 | void f5() { f3(0, 0); }
  | ^~~~
0x231f49e internal_error(char const*, ...)
???:0
0xa00958 fancy_abort(char const*, int, char const*)
???:0
0x103701e range_operator::wi_fold_in_parts(irange&, tree_node*,
generic_wide_int const&, generic_wide_int
const&, generic_wide_int const&,
generic_wide_int const&) const
???:0
0x1037b64 range_operator::fold_range(irange&, tree_node*, irange const&, irange
const&, relation_trio) const
???:0
0x1023768 operator_bitwise_not::fold_range(irange&, tree_node*, irange const&,
irange const&, relation_trio) const
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c/111921] New: GCC: 14: internal compiler error: Segmentation fault

2023-10-22 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111921

Bug ID: 111921
   Summary: GCC: 14: internal compiler error: Segmentation fault
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

When compile this program with GCC, gcc segfaults:
```
_Atomic(int) a;
const double b;
int main(void) {
  void f(void *arg) { return ; }
  return a |= b;
}
```

The function definition `f` inside main is essential to trigger this segfault,
without this func, GCC simply reports an error.

Compiler Explorer: https://gcc.godbolt.org/z/P58W6ssaG

The stack dump:
```
: In function 'main':
:5:12: error: invalid operands to binary | (have 'int' and 'double')
5 |   return a |= b;
  |   ~~   ^~
  |   |
  |   int
:3:5: internal compiler error: Segmentation fault
3 | int main(void) {
  | ^~~~
0x231f49e internal_error(char const*, ...)
???:0
0x1462bbc walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set >*))
???:0
0xda9275 walk_gimple_op(gimple*, tree_node* (*)(tree_node**, int*, void*),
walk_stmt_info*)
???:0
0xda96e9 walk_gimple_stmt(gimple_stmt_iterator*, tree_node*
(*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**,
int*, void*), walk_stmt_info*)
???:0
0xda9888 walk_gimple_seq_mod(gimple**, tree_node* (*)(gimple_stmt_iterator*,
bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*),
walk_stmt_info*)
???:0
0xda9761 walk_gimple_stmt(gimple_stmt_iterator*, tree_node*
(*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**,
int*, void*), walk_stmt_info*)
???:0
0xda9888 walk_gimple_seq_mod(gimple**, tree_node* (*)(gimple_stmt_iterator*,
bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*),
walk_stmt_info*)
???:0
0xda9761 walk_gimple_stmt(gimple_stmt_iterator*, tree_node*
(*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**,
int*, void*), walk_stmt_info*)
???:0
0xda9888 walk_gimple_seq_mod(gimple**, tree_node* (*)(gimple_stmt_iterator*,
bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*),
walk_stmt_info*)
???:0
0x11cef6b lower_nested_functions(tree_node*)
???:0
0xbea49e cgraph_node::analyze()
???:0
0xbee231 symbol_table::finalize_compilation_unit()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c/111915] New: GCC: ICEs on a program with __restrict and option `-O2 -fno-tree-vrp -fno-tree-dominator-opts -fno-tree-ccp`

2023-10-21 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111915

Bug ID: 111915
   Summary: GCC: ICEs on a program with __restrict and option `-O2
-fno-tree-vrp -fno-tree-dominator-opts -fno-tree-ccp`
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

When compile this program, GCC crashes:
```
void 
foo (int * __restrict a, int * __restrict b, int * __restrict w)
{
  for (int i = 0; i < 16; ++i)
{
  *a += w[2*i+0];
  *b += w[2*i&1];
}
}

int main()
{
  int w[32];
  int a = 0, b = 0;
  foo (, b, w);
  return 0;
}
```

Compiler Explorer: https://gcc.godbolt.org/z/8oYjE3e9j

The crash seems to be triggered solely under specific conditions: when the
-fno-tree-vrp, -fno-tree-dominator-opts, and -fno-tree-ccp options are enabled,
in conjunction with an optimization level of -O2 or higher. However, I'm
uncertain whether this combination of settings violates on any internal
conventions or requirements tied to these options.

The full stack dump:
```
: In function 'main':
:15:12: warning: passing argument 2 of 'foo' makes pointer from integer
without a cast [-Wint-conversion]
   15 |   foo (, b, w);
  |^
  ||
  |int
:2:43: note: expected 'int * restrict' but argument is of type 'int'
2 | foo (int * __restrict a, int * __restrict b, int * __restrict w)
  |  ~^
: In function 'foo':
:2:1: error: definition in block 3 follows the use
2 | foo (int * __restrict a, int * __restrict b, int * __restrict w)
  | ^~~
for SSA_NAME: _12 in statement:
vect_cst__35 = {_12, _12, _12, _12};
during GIMPLE pass: vect
:2:1: internal compiler error: verify_ssa failed
0x231f49e internal_error(char const*, ...)
???:0
0x139c15e verify_ssa(bool, bool)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c/111914] New: GCC: 14: ICE when function pointer array as arguments

2023-10-21 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111914

Bug ID: 111914
   Summary: GCC: 14: ICE when function pointer array as arguments
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/Yn354q5zP

When compile this program with `-O0`, gcc crashes:
```
 __attribute__((always_inline))
void f(int n, int (*a())[n]) {
}

void g(void)
{
  int (*a())[1];
  f(1, a);
}

```

Interestingly, `-O1` or above do not trigger the crash.

The full stack dump:
```
:2:6: warning: 'always_inline' function might not be inlinable
[-Wattributes]
2 | void f(int n, int (*a())[n]) {
  |  ^
: In function 'g':
:9:1: error: type mismatch between an SSA_NAME and its symbol
9 | }
  | ^
:9:1: error: type mismatch between an SSA_NAME and its symbol
while verifying SSA_NAME a_4 in statement
a_4 = a;
during GIMPLE pass: einline
:9:1: internal compiler error: verify_ssa failed
0x231f49e internal_error(char const*, ...)
???:0
0x139c15e verify_ssa(bool, bool)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c/111913] New: GCC: 14: -O1 compile __builtin_popcount fails while -O0 succeeds

2023-10-21 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111913

Bug ID: 111913
   Summary: GCC: 14: -O1 compile __builtin_popcount fails while
-O0 succeeds
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

When compile this program with `-O1`, gcc crashes:
```
int f(unsigned int x, unsigned int y)
{
  return __builtin_popcount (x) + __builtin_popcount (y|x--);
}
```

If change the optimization level to `-O0`, then nothing happens.

Compiler Explorer: https://gcc.godbolt.org/z/naoebKMor

The stack dump:
```
: In function 'f':
:4:1: error: invalid conversion in gimple call
4 | }
  | ^
unsigned int

int

_3 = __builtin_popcount (x_6(D));
:4:1: error: invalid conversion in gimple call
unsigned int

int

_11 = __builtin_popcount (y_7(D));
:4:1: error: type mismatch in binary expression
int

unsigned int

unsigned int

_9 = _3 + _11;
during GIMPLE pass: forwprop
:4:1: internal compiler error: verify_gimple failed
0x231f49e internal_error(char const*, ...)
???:0
0x1164659 verify_gimple_in_cfg(function*, bool, bool)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c/111912] New: GCC: 14: internal compile error when apply __transaction_atomic on logical or expr

2023-10-21 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111912

Bug ID: 111912
   Summary: GCC: 14: internal compile error when apply
__transaction_atomic on logical or expr
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

When compile this small program:
```
int a;
int f() { return __transaction_atomic (a || 1); }
```

GCC crashes, (verification link: https://gcc.godbolt.org/z/8onMYzqcv)

The full stack dump:
```
: In function 'f':
:2:40: internal compiler error: in gimplify_expr, at gimplify.cc:17510
2 | int f() { return __transaction_atomic (a || 1); }
  |^
0x231f49e internal_error(char const*, ...)
???:0
0xa00958 fancy_abort(char const*, int, char const*)
???:0
0xdbb3dc gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xdbbf48 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xdbec8a gimplify_stmt(tree_node**, gimple**)
???:0
0xdbcc33 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xdbec8a gimplify_stmt(tree_node**, gimple**)
???:0
0xdbbf48 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xdbec8a gimplify_stmt(tree_node**, gimple**)
???:0
0xdbbf48 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xdbb78d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xdbec8a gimplify_stmt(tree_node**, gimple**)
???:0
0xdbbcdf gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xdbec8a gimplify_stmt(tree_node**, gimple**)
???:0
0xdbdddb gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xdbb78d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xdbec8a gimplify_stmt(tree_node**, gimple**)
???:0
0xdbc9b7 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xdbec8a gimplify_stmt(tree_node**, gimple**)
???:0
0xdbbcdf gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c/111911] New: GCC: 14: internal compiler error: internal compiler error: in gimplify_expr, at gimplify.cc:17510

2023-10-21 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111911

Bug ID: 111911
   Summary: GCC: 14: internal compiler error: internal compiler
error: in gimplify_expr, at gimplify.cc:17510
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

When compile this program, GCC crashes:
```
int main(void) {
  if !((_Bool)(__INT_MAX__ + 1))) /
  (!((_Bool)(__INT_MAX__ + 1))
  ;
  return 1;
}
```

Complier Explorer: https://gcc.godbolt.org/z/W59roeYKP

The full stack dump:
```
: In function 'main':
:2:32: warning: integer overflow in expression of type 'int' results in
'-2147483648' [-Woverflow]
2 |   if !((_Bool)(__INT_MAX__ + 1))) /
  |^
:3:34: warning: integer overflow in expression of type 'int' results in
'-2147483648' [-Woverflow]
3 |   (!((_Bool)(__INT_MAX__ + 1))
  |  ^
cc1: warning: division by zero [-Wdiv-by-zero]
:2:10: internal compiler error: in gimplify_expr, at gimplify.cc:17510
2 |   if !((_Bool)(__INT_MAX__ + 1))) /
  |  ^
0x231f49e internal_error(char const*, ...)
???:0
0xa00958 fancy_abort(char const*, int, char const*)
???:0
0xdbb856 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xdbb3dc gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xdbb856 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xdbb3dc gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xdbb3dc gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xdbbf48 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xdbec8a gimplify_stmt(tree_node**, gimple**)
???:0
0xdbcc33 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xdbec8a gimplify_stmt(tree_node**, gimple**)
???:0
0xdbbcdf gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xdbec8a gimplify_stmt(tree_node**, gimple**)
???:0
0xdbcc33 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xdbec8a gimplify_stmt(tree_node**, gimple**)
???:0
0xdc0cd3 gimplify_body(tree_node*, bool)
???:0
0xdc112f gimplify_function_tree(tree_node*)
???:0
0xbea6e7 cgraph_node::analyze()
???:0
0xbee231 symbol_table::finalize_compilation_unit()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c/111887] GCC: 14: A potential miscompilation with __builtin_inf

2023-10-19 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111887

--- Comment #2 from wierton <141242068 at smail dot nju.edu.cn> ---
Thanks for you reply, I got it!

[Bug c/111887] New: GCC: 14: A potential miscompilation with __builtin_inf

2023-10-19 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111887

Bug ID: 111887
   Summary: GCC: 14: A potential miscompilation with __builtin_inf
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

I am uncertain whether this program contains undefined behavior, the testcase
is:
```
extern void abort (void);

void test(double f, double i)
{
  if (i != __builtin_inf())
abort ();
}

int main()
{
  test (34.0, __builtin_inf());
  return 0;
}

```

When compile it with -O0, -O1, -O2, the program normally exits, but when
compile it with -Ofast, the program abort.

Here is the verification link: https://gcc.godbolt.org/z/7YKbvha84

[Bug c/111886] New: GCC: 14: internal compiler error: in tree_to_uhwi, at tree.cc:6467

2023-10-19 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111886

Bug ID: 111886
   Summary: GCC: 14: internal compiler error: in tree_to_uhwi, at
tree.cc:6467
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

The ICE trigger:
```
void f() {
  __builtin_eh_return_data_regno(-1);;
}
```

Verification link: https://gcc.godbolt.org/z/K9178a89W

The stack dump:
```
during RTL pass: expand
: In function 'f':
:2:3: internal compiler error: in tree_to_uhwi, at tree.cc:6467
2 |   __builtin_eh_return_data_regno(-1);;
  |   ^~
0x231788e internal_error(char const*, ...)
???:0
0xa0002a fancy_abort(char const*, int, char const*)
???:0
0xca7b96 expand_builtin_eh_return_data_regno(tree_node*)
???:0
0xb79cc6 expand_builtin(tree_node*, rtx_def*, rtx_def*, machine_mode, int)
???:0
0xccd48b expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c/111882] New: GCC: 14: internal compiler error: in get_expr_operands, at tree-ssa-operands.cc:940

2023-10-19 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111882

Bug ID: 111882
   Summary: GCC: 14: internal compiler error: in
get_expr_operands, at tree-ssa-operands.cc:940
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/h9MMnxbvK

When compile this program with option -O2, gcc crashes:
```
static void __attribute__((noipa)) f(int n) {
  int i, j;
  struct S { char d[n]; int a; int b : 17; int c : 12; };
  struct S A[100][];
  for (i = 0; i < 100; i++) {
asm volatile("" : : "g"([0][0]) : "memory");
for (j = 0; j < ; j++) A[i][j].b = 2;
  }
}

void g(void) { f(1); }
```

The stack dump:
```
unhandled expression in get_expr_operands():
 
unit-size 
align:32 warn_if_not_align:0 symtab:-167332928 alias-set 3
canonical-type 0x7fe6f5ea55e8 precision:32 min  max 
pointer_to_this >
side-effects public
arg:0 
used ignored SI :3:10 size 
unit-size 
align:32 warn_if_not_align:0 context >>

during GIMPLE pass: ifcvt
: In function 'f':
:1:36: internal compiler error: in get_expr_operands, at
tree-ssa-operands.cc:940
1 | static void __attribute__((noipa)) f(int n) {
  |^
0x231788e internal_error(char const*, ...)
???:0
0xa0002a fancy_abort(char const*, int, char const*)
???:0
0x12e792d operands_scanner::get_expr_operands(tree_node**, int)
???:0
0x12e71b8 operands_scanner::get_expr_operands(tree_node**, int)
???:0
0x12e71b8 operands_scanner::get_expr_operands(tree_node**, int)
???:0
0x12e71b8 operands_scanner::get_expr_operands(tree_node**, int)
???:0
0x12e7e50 operands_scanner::parse_ssa_operands()
???:0
0x12e8cfa operands_scanner::build_ssa_operands()
???:0
0x12e8f44 update_stmt_operands(function*, gimple*)
???:0
0xd66fec gsi_insert_before(gimple_stmt_iterator*, gimple*, gsi_iterator_update)
???:0
0x1196551 tree_if_conversion(loop*, vec*)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c/111865] New: GCC: 14: internal compiler error: symtab_node::verify failed

2023-10-18 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111865

Bug ID: 111865
   Summary: GCC: 14: internal compiler error: symtab_node::verify
failed
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

When compile this program, gcc crashes:
```
register unsigned long x asm("rsp");

struct {
  int a;
} * p asm("rsp");
```

Compiler Explorer: https://godbolt.org/z/xYq8KP8M3

The stack dump:
```
:5:1: error: assembler name hash list corrupted
5 | } * p asm("rsp");
  | ^
*rsp/0 (x)
  Type: variable definition analyzed
  Visibility: force_output semantic_interposition no_reorder public
  References: 
  Referring: 
  Availability: not-ready
  Varpool flags:
:5:1: internal compiler error: symtab_node::verify failed
0x231210e internal_error(char const*, ...)
???:0
0xbd03a9 symtab_node::verify()
???:0
0xbd168f symtab_node::verify_symtab_nodes()
???:0
0xbebdab symbol_table::finalize_compilation_unit()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c/111862] New: GCC: internal compiler error: tree check: expected class 'type', have 'exceptional' (error_mark) in c_parser_omp_clause_reduction, at c/c-parser.cc:16234

2023-10-18 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111862

Bug ID: 111862
   Summary: GCC: internal compiler error: tree check: expected
class 'type', have 'exceptional' (error_mark) in
c_parser_omp_clause_reduction, at c/c-parser.cc:16234
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

The bug triggering program, compile it with option `-O1 -fopenmp-simd`, gcc
crashes:
```
union S {};
void baz (void *);

int const_1 = 0;
void f (void)
{
  struct S s;
  int i;
  #pragma omp taskloop simd reduction(+:s)
  for (i = const_1; i < 1; i++)
baz ();
}
```

Compiler Explorer: https://godbolt.org/z/361KvMv41

This bug seems similar to #110500, maybe it was not fully fixed in #110500?

Stack dump:
```
: In function 'f':
:7:10: error: 'S' defined as wrong kind of tag
7 |   struct S s;
  |  ^
:7:12: error: storage size of 's' isn't known
7 |   struct S s;
  |^
:9:11: internal compiler error: tree check: expected class 'type', have
'exceptional' (error_mark) in c_parser_omp_clause_reduction, at
c/c-parser.cc:16234
9 |   #pragma omp taskloop simd reduction(+:s)
  |   ^~~
0x231210e internal_error(char const*, ...)
???:0
0x8a8b5c tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
???:0
0xaa6d8d c_parse_file()
???:0
0xb1a0c9 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c/111856] New: GCC: 14: internal compiler error: in as_a, at machmode.h:381

2023-10-17 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111856

Bug ID: 111856
   Summary: GCC: 14: internal compiler error: in as_a, at
machmode.h:381
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

When compile this program with option `-fopenmp-simd`, gcc crashes:
```
typedef void T;

int array[1000];
#pragma omp declare simd notinbranch simdlen(4)
T foo (int i)
{
  array[i] = 555;
}
```

Compiler Explorer: https://gcc.godbolt.org/z/Tq665jvzP

Interestingly, by bypassing the `typedef` and directly defining foo's return
type as void, the crash disappears:
```
int array[1000];
#pragma omp declare simd notinbranch simdlen(4)
void foo (int i)
{
  array[i] = 555;
}
```

The stack dump:
```
during IPA pass: simdclone
: In function 'foo.simdclone.0':
:8:1: internal compiler error: in as_a, at machmode.h:381
8 | }
  | ^
0x230ff8e internal_error(char const*, ...)
???:0
0x9fe390 fancy_abort(char const*, int, char const*)
???:0
0x1fa0c9f expand_simd_clones(cgraph_node*)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c/111855] New: GCC: 14: internal compiler error: tree check: expected class 'type', have 'exceptional' (error_mark) in useless_type_conversion_p, at gimple-expr.cc:265

2023-10-17 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111855

Bug ID: 111855
   Summary: GCC: 14: internal compiler error: tree check: expected
class 'type', have 'exceptional' (error_mark) in
useless_type_conversion_p, at gimple-expr.cc:265
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

When compile this program with GCC-14, gcc throws internal compiler error:
```
extern void *memmove(void [3], const void *, __SIZE_TYPE__);

void f(void)
{
 char s[] = "12345";
 memmove(s + 1, s, 4);
}
```

Compiler Explorer: https://gcc.godbolt.org/z/5zcnehhzo

The full stack:
```
:1:27: error: declaration of type name as array of voids
1 | extern void *memmove(void [3], const void *, __SIZE_TYPE__);
  |   ^
: In function 'f':
:6:12: error: type of formal parameter 1 is incomplete
6 |  memmove(s + 1, s, 4);
  |  ~~^~~
:6:2: internal compiler error: tree check: expected class 'type', have
'exceptional' (error_mark) in useless_type_conversion_p, at gimple-expr.cc:265
6 |  memmove(s + 1, s, 4);
  |  ^~~
0x230ff8e internal_error(char const*, ...)
???:0
0x8a8944 tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
???:0
0xdb9a31 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xdb9247 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xdbc21a gimplify_stmt(tree_node**, gimple**)
???:0
0xdba1c3 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xdbc21a gimplify_stmt(tree_node**, gimple**)
???:0
0xdb926f gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xdbc21a gimplify_stmt(tree_node**, gimple**)
???:0
0xdbe233 gimplify_body(tree_node*, bool)
???:0
0xdbe68f gimplify_function_tree(tree_node*)
???:0
0xbe7db7 cgraph_node::analyze()
???:0
0xbeb901 symbol_table::finalize_compilation_unit()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c/111834] New: GCC: 14: out of memory when __builtin_return_address receive a large constant

2023-10-16 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111834

Bug ID: 111834
   Summary: GCC: 14: out of memory when __builtin_return_address
receive a large constant
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/7d63G6fWT

Testcase is pasted below:
```
void *retaddr;

void foo (void) {
  retaddr = __builtin_return_address (1084850891);
}
```

When compile it with GCC-14, it quickly used up all 8G memory on my PC.

[Bug c/111833] GCC: 14: hangs on a simple for loop

2023-10-16 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111833

--- Comment #1 from wierton <141242068 at smail dot nju.edu.cn> ---
The compiler explore link above is broken, here is the link:
https://gcc.godbolt.org/z/779zzjcze

[Bug c/111833] New: GCC: 14: hangs on a simple for loop

2023-10-16 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111833

Bug ID: 111833
   Summary: GCC: 14: hangs on a simple for loop
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: [https://gcc.godbolt.org/](https://gcc.godbolt.org/)

Here is the code snippet that is causing the issue:

```c
unsigned char a[1];
unsigned char b;

void f(void) {
  unsigned char r = 0;
  int n;
  for (n = 8; n / sizeof(a); ++n) {
b += b;
r += b;
  }
}
```

This bug shares the same options as bug #111820, but the root cause seems to be
different:

While bug #111820 appears to get stuck in a loop when the initial value is zero
(as suggested by the comment `Maybe the loop should terminate when begin is
zero.`), this particular bug causes a hang starting from the initial value of
8. This suggests that the issue may not be tied to the initial loop value, but
some other aspect of the loop's iteration or the operations within it.

[Bug c/111821] New: GCC: 14: continue to consume memory until OOM

2023-10-14 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111821

Bug ID: 111821
   Summary: GCC: 14: continue to consume memory until OOM
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

The bug triggering program:
```
typedef union { char a[1003263430]; }
__attribute__((__packed__)) T;
void f(const void *p) {
unsigned short v;
*(T *)(void *)() = *(const T *)p;
}
```

When compile it with `gcc -Og`, gcc used up 8GB of memory on my computer, but
when compile with other options like `-Os`, it normally returns.

Compiler Explorer: https://godbolt.org/z/73n953Y3j

[Bug c/111820] New: GCC: 14: hangs with a simple while loop

2023-10-14 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111820

Bug ID: 111820
   Summary: GCC: 14: hangs with a simple while loop
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://godbolt.org/z/ezdG5GGd8

When compile below program with option `-O3 -fno-tree-vrp`, GCC consumes upto
46 seconds to finish:
```
int r;
int r_0;

void f (void)
{
  int n = 0;
  while (-- n)
{
  r_0 += r ;
  r  += r;
  r  += r ;
  r  += r ;
  r  >= r ;
  r  += r ;
}
}
```

[Bug c/111819] New: GCC: 14: internal compiler error: in fold_offsetof, at c-family/c-common.cc:6877

2023-10-14 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111819

Bug ID: 111819
   Summary: GCC: 14: internal compiler error: in fold_offsetof, at
c-family/c-common.cc:6877
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

The bug triggering program:
```
long long a;
void f(_Complex double x) {
  (int *)&__imag(
  *(_Complex double *)((char *) + 16));
}
```

This bug can be verified at: https://godbolt.org/z/6d98f8YT7

The full stack dump:
```
: In function 'f':
:4:7: internal compiler error: in fold_offsetof, at
c-family/c-common.cc:6877
4 |   *(_Complex double *)((char *) + 16));
  |   ^
0x22ff3ee internal_error(char const*, ...)
???:0
0x9fc0a8 fancy_abort(char const*, int, char const*)
???:0
0xa4f1d8 build_unary_op(unsigned int, tree_code, tree_node*, bool)
???:0
0xa5c176 parser_build_unary_op(unsigned int, tree_code, c_expr)
???:0
0xaa468d c_parse_file()
???:0
0xb17919 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c/111818] New: GCC: 14: internal compiler error: tree check: expected tree that contains 'decl common' structure, have 'integer_cst' in tree_could_trap_p, at tree-eh.cc:2733

2023-10-14 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111818

Bug ID: 111818
   Summary: GCC: 14: internal compiler error: tree check: expected
tree that contains 'decl common' structure, have
'integer_cst' in tree_could_trap_p, at tree-eh.cc:2733
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

When compile below program with GCC-14 and option `-O1`, GCC-14 crashes:
```
#define DUMMY_VALUE 0x12345678
static void foo(const volatile unsigned int x, void *p) {
  __builtin_memcpy(p, , sizeof x);
  __builtin_memcpy(p, , sizeof x);
}

void bar(int type, void *number) {
  switch (type) {
  case 1: foo(DUMMY_VALUE, number); break;
  case 7: foo(0, number); break;
  case 8: foo(0, number); break;
  case 9: foo(0, number); break;
  }
}
```

The crash reproducer: https://godbolt.org/z/7sP8zc3Kc

And the full stack dump:
```
: In function 'foo':
:3:23: warning: passing argument 2 of '__builtin_memcpy' discards
'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers]
3 |   __builtin_memcpy(p, , sizeof x);
  |   ^~
:3:23: note: expected 'const void *' but argument is of type 'const
volatile unsigned int *'
:4:23: warning: passing argument 2 of '__builtin_memcpy' discards
'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers]
4 |   __builtin_memcpy(p, , sizeof x);
  |   ^~
:4:23: note: expected 'const void *' but argument is of type 'const
volatile unsigned int *'
during RTL pass: expand
In function 'foo',
inlined from 'bar' at :9:11:
:3:3: internal compiler error: tree check: expected tree that contains
'decl common' structure, have 'integer_cst' in tree_could_trap_p, at
tree-eh.cc:2733
3 |   __builtin_memcpy(p, , sizeof x);
  |   ^
0x22ff3ee internal_error(char const*, ...)
???:0
0x8a8243 tree_contains_struct_check_failed(tree_node const*,
tree_node_structure_enum, char const*, int, char const*)
???:0
0xc9ab0e set_mem_attributes_minus_bitpos(rtx_def*, tree_node*, int,
poly_int<1u, long>)
???:0
0xcc6c35 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
???:0
0xcd3083 store_expr(tree_node*, rtx_def*, int, bool, bool)
???:0
0xcd4d66 expand_assignment(tree_node*, tree_node*, bool)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c/111817] New: GCC: 14: internal compiler error: in expand_asm_stmt, at cfgexpand.cc:3389

2023-10-14 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111817

Bug ID: 111817
   Summary: GCC: 14: internal compiler error: in expand_asm_stmt,
at cfgexpand.cc:3389
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

The bug triggering program:
```
static int foo(int x, int y, int z) {
  int b;
  asm("" : "=a"(b), "\n="(x) : "0"(y), "1"(x), "mr"(z));
  return x;
}
```

The crash can be verfied at link: https://godbolt.org/z/6d7csd8xv

The full stack dump:
```
: In function 'foo':
:3:3: warning: output constraint '=' for operand 1 is not at the
beginning
3 |   asm("" : "=a"(b), "\n="(x) : "0"(y), "1"(x), "mr"(z));
  |   ^~~
:3:3: warning: output constraint '=' for operand 1 is not at the
beginning
:1:12: warning: output constraint '=' for operand 1 is not at the
beginning
1 | static int foo(int x, int y, int z) {
  |^~~
:1:12: warning: output constraint '=' for operand 1 is not at the
beginning
:1:12: warning: output constraint '=' for operand 1 is not at the
beginning
:1:12: warning: output constraint '=' for operand 1 is not at the
beginning
:1:12: warning: output constraint '=' for operand 1 is not at the
beginning
:1:12: warning: output constraint '=' for operand 1 is not at the
beginning
:1:12: warning: output constraint '=' for operand 1 is not at the
beginning
:1:12: warning: output constraint '=' for operand 1 is not at the
beginning
:1:12: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
5 | }
  | ^
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output constraint '=' for operand 1 is not at the
beginning
:5:1: warning: output 

[Bug c/111816] New: GCC: 14: internal compiler error: Segmentation fault at c_parser_parse_gimple_body

2023-10-14 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111816

Bug ID: 111816
   Summary: GCC: 14: internal compiler error: Segmentation fault
at c_parser_parse_gimple_body
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

When compile this program with GCC-14, GCC crashes:
```
__GIMPLE (ssa) int foo (int *a)
{
  return 0;
  return 0;
}
```

Compiler Explorer: https://godbolt.org/z/zecdo68WE

The full stack dump:
```
: In function 'foo':
:5:1: internal compiler error: Segmentation fault
5 | }
  | ^
0x22ff3ee internal_error(char const*, ...)
???:0
0xaad8ac c_parser_parse_gimple_body(c_parser*, char*, c_declspec_il,
profile_count)
???:0
0xaa468d c_parse_file()
???:0
0xb17919 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c/111810] New: GCC-14 segfault: error: expected declaration or statement at end of input

2023-10-14 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111810

Bug ID: 111810
   Summary: GCC-14 segfault: error: expected declaration or
statement at end of input
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

When compile this program with `gcc-14 -O0`, gcc crashes:
```
void = {0};
void uninliner_1() {
  {}
inline __RTL test(void) {
  uninliner_1();
```

This crash can be verified at https://godbolt.org/z/rc9oW43EE

The full stack backtrace is pasted below:

:1:6: error: expected identifier or '(' before '=' token
1 | void = {0};
  |  ^
: In function 'uninliner_1':
:4:14: warning: return type defaults to 'int' [-Wimplicit-int]
4 | inline __RTL test(void) {
  |  ^~~~
: In function 'test':
:5:3: error: no closing brace
5 |   uninliner_1();
  |   ^~~
: At top level:
:5:3: error: expected declaration or statement at end of input
:5:3: internal compiler error: Segmentation fault
0x22ff3ee internal_error(char const*, ...)
???:0
0xa2621e finish_function(unsigned int)
???:0
0xaa468d c_parse_file()
???:0
0xb17919 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1

[Bug c/111809] GCC-14: internal error, internal compiler error: in release_function_body, at cgraph.cc:1805

2023-10-14 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111809

--- Comment #1 from wierton <141242068 at smail dot nju.edu.cn> ---
Full stack backtrace:

: In function 'bar':
:8:1: error: SSA name '' with version 3 has no definition
8 | }
  | ^
At top level:
cc1: internal compiler error: in release_function_body, at cgraph.cc:1805
0x22ff3ee internal_error(char const*, ...)
???:0
0x9fc0a8 fancy_abort(char const*, int, char const*)
???:0
0xbd8857 cgraph_node::release_body(bool)
???:0
0xbde851 cgraph_node::remove()
???:0
0xbe92d1 symbol_table::finalize_compilation_unit()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.

[Bug c/111809] New: GCC-14: internal error, internal compiler error: in release_function_body, at cgraph.cc:1805

2023-10-14 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111809

Bug ID: 111809
   Summary: GCC-14: internal error, internal compiler error: in
release_function_body, at cgraph.cc:1805
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Reproducer: https://godbolt.org/z/MP7qnTKz6

when compile this with `gcc-14 -O0 -fgimple`, gcc crashes:
```
inline __GIMPLE (ssa) void
bar (void)
{
  int _3;

__BB(2):
  return;
}
```

[Bug c/110737] New: GCC: internal compiler error: Segmentation fault when processing __builtin_isinf and _Atomic long double together

2023-07-19 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110737

Bug ID: 110737
   Summary: GCC: internal compiler error: Segmentation fault when
processing __builtin_isinf and _Atomic long double
together
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

When attempting to compile below program using gcc-14 with option `gcc-14
small.c`, gcc throws internal error.
```
_Atomic long double c;
void f(void);
void g(void) { __builtin_isinf(c /= f()); }
```

The output of gcc is pasted below:
```
: In function 'g':
:3:1: error: void value not ignored as it ought to be
3 | void g(void) { __builtin_isinf(c /= f()); }
  | ^~~~
:3:34: internal compiler error: Segmentation fault
3 | void g(void) { __builtin_isinf(c /= f()); }
  |  ^~
0x21594ee internal_error(char const*, ...)
???:0
0xd6ec47 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xd7182a gimplify_stmt(tree_node**, gimple**)
???:0
0xd6f79b gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xd7182a gimplify_stmt(tree_node**, gimple**)
???:0
0xd6ec6a gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xd7182a gimplify_stmt(tree_node**, gimple**)
???:0
0xd6ec04 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xd7182a gimplify_stmt(tree_node**, gimple**)
???:0
0xd72cc3 gimplify_body(tree_node*, bool)
???:0
0xd7311f gimplify_function_tree(tree_node*)
???:0
0xbaffa7 cgraph_node::analyze()
???:0
0xbb3af1 symbol_table::finalize_compilation_unit()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

The above segment fault can be verified at compiler explorer:
https://gcc.godbolt.org/z/Ghxe5Mc6e

[Bug target/110736] gcc: internal compiler error: in change_stack, at reg-stack.cc:2709

2023-07-19 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110736

--- Comment #1 from wierton <141242068 at smail dot nju.edu.cn> ---
It looks like this is similar to bug 110667, but ICEs under different
optimization option (-Ofast with -Os).

[Bug c/110736] New: gcc: internal compiler error: in change_stack, at reg-stack.cc:2709

2023-07-19 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110736

Bug ID: 110736
   Summary: gcc: internal compiler error: in change_stack, at
reg-stack.cc:2709
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

The bug triggering program:
```
long double a, b;
long double f(long double x) {
  asm("sqxbr\t%0,%1" : "=f"(a) : "f"(x));
  return a;
}

int main(void) {
  return b / f(0x1.1p+0L);
}
```

When attempting to compile it using the option `gcc-14 -Os small.c`, gcc
crashes:
```
: In function 'f':
:3:3: error: output constraint 0 must specify a single register
3 |   asm("sqxbr\t%0,%1" : "=f"(a) : "f"(x));
  |   ^~~
during RTL pass: stack
:5:1: internal compiler error: in change_stack, at reg-stack.cc:2709
5 | }
  | ^
0x21594ee internal_error(char const*, ...)
???:0
0x9cf35e fancy_abort(char const*, int, char const*)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

This crash can be verified at compiler explorer:
https://gcc.godbolt.org/z/EKrY7s576

[Bug c/110699] New: internal compiler error: tree check: expected array_type, have error_mark in array_ref_low_bound, at tree.cc:12754

2023-07-17 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110699

Bug ID: 110699
   Summary: internal compiler error: tree check: expected
array_type, have error_mark in array_ref_low_bound, at
tree.cc:12754
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

When compiling below program using gcc-14 with option `gcc-14 a.c`, gcc-14
crashes:
```
typedef __attribute__((__vector_size__(64))) int T;

void f(void) {
  extern char a[64], b[64];
  void *p = a;
  T q = *(T *)[0];
}

void g() {
  extern char b;
}
```

GCC's output is pasted below:
```
: In function 'g':
:10:15: error: conflicting types for 'b'; have 'char'
   10 |   extern char b;
  |   ^
:4:22: note: previous declaration of 'b' with type 'char[64]'
4 |   extern char a[64], b[64];
  |  ^
: In function 'f':
:6:17: internal compiler error: tree check: expected array_type, have
error_mark in array_ref_low_bound, at tree.cc:12754
6 |   T q = *(T *)[0];
  |~^~~
0x215104e internal_error(char const*, ...)
???:0
0x896b1b tree_check_failed(tree_node const*, char const*, int, char const*,
...)
???:0
0xd6c895 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xd6d557 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xd6db1d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xd6cf6a gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xd7053a gimplify_stmt(tree_node**, gimple**)
???:0
0xd6d53e gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xd7053a gimplify_stmt(tree_node**, gimple**)
???:0
0xd6e4ab gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xd7053a gimplify_stmt(tree_node**, gimple**)
???:0
0xd6d914 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xd7053a gimplify_stmt(tree_node**, gimple**)
???:0
0xd719d3 gimplify_body(tree_node*, bool)
???:0
0xd71e2f gimplify_function_tree(tree_node*)
???:0
0xbaeba7 cgraph_node::analyze()
???:0
0xbb26f1 symbol_table::finalize_compilation_unit()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

This can be verified by visiting the Compiler Explorer:
https://gcc.godbolt.org/z/jPhnfG4f3

[Bug c/110693] New: internal compiler error: Segmentation fault

2023-07-16 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110693

Bug ID: 110693
   Summary: internal compiler error: Segmentation fault
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

When compiling below program using gcc-14 with option `gcc-14 a.c`, gcc-14
crashes:
```
char global;

void bar (void);

void __GIMPLE (ssa)
foo (char * p)
{
  __BB(2):
  if (p_2(D) == _Literal (char *)[2])
goto __BB3;
  else
goto __BB4;

  __BB(3):
  bar ();
  goto __BB4;

  __BB(4):
  return;
}

```

GCC's output is pasted below:
```
:5:6: error: '__GIMPLE' only valid with '-fgimple'
5 | void __GIMPLE (ssa)
  |  ^~~~
: In function 'foo':
:9:41: error: subscripted value is neither array nor pointer nor vector
9 |   if (p_2(D) == _Literal (char *)[2])
  | ^
:9:44: error: invalid _Literal before ')' token
9 |   if (p_2(D) == _Literal (char *)[2])
  |^
:20:1: internal compiler error: Segmentation fault
   20 | }
  | ^
0x2150dee internal_error(char const*, ...)
???:0
0xb510f3 unchecked_make_edge(basic_block_def*, basic_block_def*, int)
???:0
0xa7d754 c_parser_parse_gimple_body(c_parser*, char*, c_declspec_il,
profile_count)
???:0
0xa7477d c_parse_file()
???:0
0xae3e59 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

This can be verified by visiting the Compiler Explorer:
https://gcc.godbolt.org/z/To9vMd4z5

[Bug c/110682] New: GCC, ICE: internal compiler error: in gimplify_expr, at gimplify.cc:16771

2023-07-16 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110682

Bug ID: 110682
   Summary: GCC, ICE: internal compiler error: in gimplify_expr,
at gimplify.cc:16771
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

When compiling below program using gcc-14 with option `gcc-14 -Ofast a.c`,
gcc-14 crashes:
```
struct a {
  const signed char b;
};

void f(volatile struct a *c) {
  c - 0 % c->b;
  struct a c = {1};
}
```

GCC's output is pasted below:
```
: In function 'f':
:7:12: error: 'c' redeclared as different kind of symbol
7 |   struct a c = {1};
  |^
:5:27: note: previous definition of 'c' with type 'volatile struct a *'
5 | void f(volatile struct a *c) {
  |~~~^
:6:5: internal compiler error: in gimplify_expr, at gimplify.cc:16771
6 |   c - 0 % c->b;
  |   ~~^~
0x2150dee internal_error(char const*, ...)
???:0
0x9ce06c fancy_abort(char const*, int, char const*)
???:0
0xd7057a gimplify_stmt(tree_node**, gimple**)
???:0
0xd6d9ba gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xd7057a gimplify_stmt(tree_node**, gimple**)
???:0
0xd6e4eb gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xd7057a gimplify_stmt(tree_node**, gimple**)
???:0
0xd6d954 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xd7057a gimplify_stmt(tree_node**, gimple**)
???:0
0xd71a13 gimplify_body(tree_node*, bool)
???:0
0xd71e6f gimplify_function_tree(tree_node*)
???:0
0xbaebe7 cgraph_node::analyze()
???:0
0xbb2731 symbol_table::finalize_compilation_unit()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

This can be verified by visiting the Compiler Explorer:
https://gcc.godbolt.org/z/5951jvono

[Bug c/110667] New: gcc-14, ICE: internal compiler error: in replace_reg, at reg-stack.cc:722

2023-07-14 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110667

Bug ID: 110667
   Summary: gcc-14, ICE: internal compiler error: in replace_reg,
at reg-stack.cc:722
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

When compiling below program using gcc-14 with option `gcc-14 -Ofast a.c`,
gcc-14 crashes:
```
#include 
#include 

void f() {
  long double res = 0;
  asm("" : "="(res) : "f"(40.), "f"(2.));
  assert(res == 42.);
}
```

GCC's output is pasted below:
```
: In function 'f':
:6:3: error: output constraint 0 must specify a single register
6 |   asm("" : "="(res) : "f"(40.), "f"(2.));
  |   ^~~
during RTL pass: stack
:8:1: internal compiler error: in replace_reg, at reg-stack.cc:722
8 | }
  | ^
0x214e13e internal_error(char const*, ...)
???:0
0x9cd8e8 fancy_abort(char const*, int, char const*)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

This can be verified by visiting the Compiler Explorer:
https://gcc.godbolt.org/z/cbYGeaze8

[Bug c/110603] New: GCC, ICE: internal compiler error: in verify_range, at value-range.cc:1104

2023-07-09 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110603

Bug ID: 110603
   Summary: GCC, ICE: internal compiler error: in verify_range, at
value-range.cc:1104
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

The testing program:
```
typedef long unsigned int size_t;
void *memcpy(void *, const void *, size_t);
int snprintf(char *restrict, size_t, const char *restrict, ...);

extern char a[2];
void test_func_on_line_62(void) {
  memcpy(a, "12", sizeof("12") - 1);
  const int res = snprintf(0, 0, "%s", a);
  if (res <= 3)
do {
  extern void f(void);
  f();
} while (0);
}
```

When attempting to compile it with `gcc-14 -O2 small.c`, gcc-14 crashes:
```
during GIMPLE pass: strlen
: In function 'test_func_on_line_62':
:6:6: internal compiler error: in verify_range, at value-range.cc:1104
6 | void test_func_on_line_62(void) {
  |  ^~~~
0x213b0ee internal_error(char const*, ...)
???:0
0x9ca9f8 fancy_abort(char const*, int, char const*)
???:0
0x13df0f7 irange::set(tree_node*, generic_wide_int const&,
generic_wide_int const&, value_range_kind)
???:0
0x1e24a5d handle_printf_call(gimple_stmt_iterator*, pointer_query&)
???:0
0x12d3d86 strlen_pass::check_and_optimize_call(bool*)
???:0
0x12d4109 strlen_pass::check_and_optimize_stmt(bool*)
???:0
0x12d4494 strlen_pass::before_dom_children(basic_block_def*)
???:0
0x1d98997 dom_walker::walk(basic_block_def*)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

This crash can be verified at https://gcc.godbolt.org/z/439GM47z9

[Bug c/110575] New: gcc: internal compiler error: tree check: expected class 'type', have 'exceptional' (error_mark) in build_aligned_type

2023-07-06 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110575

Bug ID: 110575
   Summary: gcc: internal compiler error: tree check: expected
class 'type', have 'exceptional' (error_mark) in
build_aligned_type
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

The testcase:
```
void __GIMPLE(ssa, startwith("slp")) bar() {
  a = __MEM((int *restrict)b(c));
}
```

When attempting to compile this program using `gcc-14` with option `-O0`, gcc
reports internal compiler error as below:
```
:1:6: error: '__GIMPLE' only valid with '-fgimple'
1 | void __GIMPLE(ssa, startwith("slp")) bar() {
  |  ^~~~
: In function 'bar':
:2:3: error: 'a' undeclared (first use in this function)
2 |   a = __MEM((int *restrict)b(c));
  |   ^
:2:3: note: each undeclared identifier is reported only once for each
function it appears in
:2:13: error: unknown type name 'v16si'
2 |   a = __MEM((int *restrict)b(c));
  | ^
:2:3: internal compiler error: tree check: expected class 'type', have
'exceptional' (error_mark) in build_aligned_type, at tree.cc:5700
2 |   a = __MEM((int *restrict)b(c));
  |   ^
0x213983e internal_error(char const*, ...)
???:0
0x8959fe tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
???:0
0xa7aeae c_parser_parse_gimple_body(c_parser*, char*, c_declspec_il,
profile_count)
???:0
0xa71add c_parse_file()
???:0
0xae1149 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1
```

This behavior can be verified by visiting the CompilerExplorer: 
https://gcc.godbolt.org/z/8d8GGaPze

[Bug c/110500] New: gcc: internal compiler error: tree check: expected class 'type', have 'exceptional' (error_mark) in c_parser_omp_clause_allocate

2023-06-30 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110500

Bug ID: 110500
   Summary: gcc: internal compiler error: tree check: expected
class 'type', have 'exceptional' (error_mark) in
c_parser_omp_clause_allocate
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

The program:
```
$ cat small.c
int f, l, ll, r;

void foo(int i1, int i2, int p, int s, int nth, int *q, int ntm) {
#pragma omp distribute parallel for simd \
private (p) firstprivate (f) collapse(1) dist_schedule(static, 16) \
if (parallel: i2) if(simd: i1) default(shared) shared(s) reduction(+:r)
num_threads (nth) proc_bind(spread) \
lastprivate (l) schedule(static, 4) nontemporal(ntm) \
safelen(8) simdlen(4) aligned(q: 32) order(concurrent) allocate
(omp_default_mem_alloc:f)
  for (int i = 0; i < 64; i++)
ll++;
}
```

When compile it using gcc-14 with option `-fopenmp-simd -O0`, gcc reports
internal compiler errors as below:
```
: In function 'foo':
:8:70: error: 'omp_default_mem_alloc' undeclared (first use in this
function)
8 | safelen(8) simdlen(4) aligned(q: 32) order(concurrent) allocate
(omp_default_mem_alloc:f)
  | 
^
:8:70: note: each undeclared identifier is reported only once for each
function it appears in
:4:9: internal compiler error: tree check: expected class 'type', have
'exceptional' (error_mark) in c_parser_omp_clause_allocate, at
c/c-parser.cc:16332
4 | #pragma omp distribute parallel for simd \
  | ^~~
0x213097e internal_error(char const*, ...)
???:0
0x8947e8 tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
???:0
0xa7029d c_parse_file()
???:0
0xadf919 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

This behavior can be verified by visiting the CompilerExplorer:
https://gcc.godbolt.org/z/73436b54M

[Bug middle-end/96365] GCC report impossible constraint on possible inline assembly output constraints

2023-06-14 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96365

wierton <141242068 at smail dot nju.edu.cn> changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |WONTFIX

--- Comment #3 from wierton <141242068 at smail dot nju.edu.cn> ---
Compiler has no need to take it as a CSP problem.

[Bug c/110154] When compiling __builtin_frame_address with a relatively large argument, GCC-trunk takes up a significant amount of time.

2023-06-07 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110154

wierton <141242068 at smail dot nju.edu.cn> changed:

   What|Removed |Added

 Resolution|--- |INVALID
 Status|UNCONFIRMED |RESOLVED

--- Comment #1 from wierton <141242068 at smail dot nju.edu.cn> ---
not a bug

[Bug c/110154] New: When compiling __builtin_frame_address with a relatively large argument, GCC-trunk takes up a significant amount of time.

2023-06-07 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110154

Bug ID: 110154
   Summary: When compiling __builtin_frame_address with a
relatively large argument, GCC-trunk takes up a
significant amount of time.
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

This behavior can be verified on https://gcc.godbolt.org/z/7967MTMrP

When compile below program with gcc:
```
void *h() {
  return __builtin_frame_address(0xF);
}
```


gcc takes over 40 seconds to finish:
```
$ time gcc-14 -c -O2 a.c
gcc-14 -c -O2 a.c  43.33s user 1.04s system 99% cpu 44.381 total
```

in contrast, clang immediately returns:
```
$ clang-17 -c -O2 a.c
:2:10: error: argument value 1048575 is outside the valid range [0,
65535]
2 |   return __builtin_frame_address(0xF);
  |  ^   ~~~
1 error generated.
Compiler returned: 1
```

[Bug middle-end/109917] gcctk hangs at -O0 but normally terminates at -O2

2023-05-20 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109917

--- Comment #2 from wierton <141242068 at smail dot nju.edu.cn> ---
(In reply to Andrew Pinski from comment #1)
> Dup of bug  109520.
> 
> Where is this code located anyways?
> 
> *** This bug has been marked as a duplicate of bug 109520 ***

Thanks for your reply. This test case is mutated from the file 'asmgoto-5.c'
which locates at gcc's testsuite: 'gcc/gcc/testsuite/gcc.c-torture/compile'.

[Bug c/109917] New: gcctk hangs at -O0 but normally terminates at -O2

2023-05-20 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109917

Bug ID: 109917
   Summary: gcctk hangs at -O0 but normally terminates at -O2
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Below is the testcase:
```
int foo(int a0, int a1, int a2, int a3, int a4, int a5,
int a6, int a7, int a8, int a9, int a10, int a11,
int a12, int a13, int a14, int a15, int a16) {
  register int v0 asm("rax") = a3;
  register int v5 asm("rdi") = a8;
  register int v1 asm("rbx") = a4;
  register int v2 asm("rcx") = a5;
  register int v3 asm("rdx") = a6;
  register int v4 asm("rsi") = a7;

  register int v6 asm("r8") = a9;
  register int v7 asm("r9") = a10;
  register int v8 asm("r10") = a11;
  register int v9 asm("r11") = a12;
  register int v10 asm("r12") = a13;
  register int v11 asm("r13") = a14;
  register int v12 asm("r14") = a15;
  register int v13 asm("r15") = a16;
  int x;

  asm goto("" : "=r"(x) : : : lab);
lab:
  return v0 + v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8 + v9 +
 v10 + v11 + v12 + v13 + a0 + a1 + a2;
}

```

When compile it with gcctk -O0, gcctk hangs, my gcctk version:
```
$ gcctk -v
Using built-in specs.
COLLECT_GCC=./install/bin/gcc
COLLECT_LTO_WRAPPER=/home/wierton/disk/gcc-project-trunk-compile/install/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /home/wierton/gcc-project-trunk/configure
--prefix=/home/wierton/disk/gcc-project-trunk-compile/install
--enable-languages=c,c++ --disable-bootstrap --disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230520 (experimental) (GCC)

$ gcctk --version
gcc (GCC) 14.0.0 20230520 (experimental)
Copyright (C) 2023 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 middle-end/109842] New: GCC-12 hangs on simple piece of inline assembly code

2023-05-13 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109842

Bug ID: 109842
   Summary: GCC-12 hangs on simple piece of inline assembly code
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: middle-end
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

The bug-triggering testcase:

```
$ cat c.c
static int t;

int f_tt;
int f(void) {
  int tt1;
  asm("" : "=r"(f_tt), "=r"(tt1));
  t = tt1;
  return f_tt;
}

```

When compiled with `gcc-12 -O2`, gcc hangs
```
-> tmp $ gcc-12 -O2 c.c
^C
```

My gcc version:
```
-> tmp $ gcc-12 -v
Using built-in specs.
COLLECT_GCC=gcc-12
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/12/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
12.1.0-2ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-12/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-12
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin
--enable-default-pie --with-system-zlib --enable-libphobos-checking=release
--with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch
--disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-12-sZcx2y/gcc-12-12.1.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-12-sZcx2y/gcc-12-12.1.0/debian/tmp-gcn/usr
--enable-offload-defaulted --without-cuda-driver --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.1.0 (Ubuntu 12.1.0-2ubuntu1~22.04)

```

[Bug c/104983] New: gcc ignore side effect inside CommaExpr and failed to update value variable's value

2022-03-18 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104983

Bug ID: 104983
   Summary: gcc ignore side effect inside CommaExpr and failed to
update value variable's value
   Product: gcc
   Version: 8.4.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

The code:
```
int main() {
  int a = 0;
  unsigned long long one = 1;
  unsigned long long crf1 = 0;
  unsigned long long crf2 = 0;
  unsigned long long crf3 = 0;
  unsigned long long *cty1[] = {};
  unsigned long long *cty2[] = {};
  unsigned long long *cty3[] = {};
  ((-1ULL / (0xull + (*cty1[0]))) < a++,
  ((unsigned long long)((*cty2[0]) * (*cty3[0];
  if (a != 1) __builtin_abort();
  return 0;
}
```

Note that, a is updated only once in the above expression, and -1ull is
unsigned type, it should not trigger integer overflow.

But when compile the above code with -fopen-simd, the generated executable will
abort.

```
$ gcc -fopenmp-simd a.c -o a.out && ./a.out
[1]2409988 abort (core dumped)  ./a.out
```

My gcc version is:
```
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc-8
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 8.4.0-3ubuntu2'
--with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.4.0 (Ubuntu 8.4.0-3ubuntu2)
```