[Bug c++/100326] Crash with `#pragma GCC unroll` when calling value which can't be called in template function

2024-02-08 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100326

--- Comment #3 from Andrew Pinski  ---
I even tried:
```
template void f(T v) {
#pragma GCC unroll v()
for (int i = 0; i < 10; i++) {
}
} 

int main() {
  f(0);
}
```

[Bug c++/100326] Crash with `#pragma GCC unroll` when calling value which can't be called in template function

2024-02-08 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100326

--- Comment #2 from Andrew Pinski  ---
This seems to be fixed on the trunk.

I think by r14-6193-g59be79fd596ec8 .

[Bug c++/100326] Crash with `#pragma GCC unroll` when calling value which can't be called in template function

2021-04-29 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100326

Richard Biener  changed:

   What|Removed |Added

 Ever confirmed|0   |1
   Keywords||ice-on-invalid-code
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2021-04-29

--- Comment #1 from Richard Biener  ---
Confirmed.

#0  0x00d66842 in cp_parser_pragma_unroll (parser=0x765977b8, 
pragma_tok=0x77f2f0c8)
at /home/rguenther/src/gcc3/gcc/cp/parser.c:44896
44896 if (!INTEGRAL_TYPE_P (TREE_TYPE (expr))
(gdb) l
44891 location_t location = cp_lexer_peek_token (parser->lexer)->location;
44892 tree expr = cp_parser_constant_expression (parser);
44893 unsigned short unroll;
44894 expr = maybe_constant_value (expr);
44895 HOST_WIDE_INT lunroll = 0;
44896 if (!INTEGRAL_TYPE_P (TREE_TYPE (expr))
44897 || TREE_CODE (expr) != INTEGER_CST
44898 || (lunroll = tree_to_shwi (expr)) < 0
44899 || lunroll >= USHRT_MAX)
44900   {
(gdb) p debug_tree (expr)
 >
used VOID t.ii:1:31
align:8 warn_if_not_align:0 context >
t.ii:2:25 start: t.ii:2:24 finish: t.ii:2:26>

so we parsed this to an invalid GENERIC CALL_EXPR with a NULL TREE_TYPE

(gdb) p expr->typed.type
$3 = 

it should have at least been error_mark_node (or void_type_node).