public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c/99211] New: gcc fails on program which overrides __builtin_clzll @ 2021-02-23 3:32 zhan3299 at purdue dot edu 2021-02-23 8:27 ` [Bug c/99211] " rguenth at gcc dot gnu.org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: zhan3299 at purdue dot edu @ 2021-02-23 3:32 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99211 Bug ID: 99211 Summary: gcc fails on program which overrides __builtin_clzll Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: zhan3299 at purdue dot edu Target Milestone: --- GCC fails to compile the attached code: https://godbolt.org/z/sdqq3M One interesting thing is that, only when we override __builtin_clzll this issue will occur. If we replace the __builtin_clzll as any other builtin function (e.g., __builtin_expect), GCC will accept the program with a conflicting type warning: https://godbolt.org/z/5c45T6 For other compilers, Clang rejects such conflicts with built-in functions: https://godbolt.org/z/9WzTKP Icc accepts and successfully compiles it (with warnings): https://godbolt.org/z/W4zK89 $ cat test.c struct S { int a; }; struct S __builtin_clzll(long x) { if (x == 1) { struct S y = { .a = 1 }; return y; } else { struct S y = { .a = __builtin_clzll(1).a + 1 }; return y; } } int main() { return __builtin_clzll(10).a; } $ gcc test.c test.c: In function '__builtin_clzll': test.c:10:16: internal compiler error: in wide_int_to_tree_1, at tree.c:1644 10 | struct S y = { .a = __builtin_clzll(1).a + 1 }; | ^ 0x1a31d99 internal_error(char const*, ...) ???:0 0x6877ad fancy_abort(char const*, int, char const*) ???:0 0x9bed4a fold_build_call_array_loc(unsigned int, tree_node*, tree_node*, int, tree_node**) ???:0 0x6e1010 build_function_call_vec(unsigned int, vec<unsigned int, va_heap, vl_ptr>, tree_node*, vec<tree_node*, va_gc, vl_embed>*, vec<tree_node*, va_gc, vl_embed>*, tree_node*) ???:0 0x7322e9 c_parse_file() ???:0 0x7a02c2 c_common_parse_file() ???:0 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/99211] gcc fails on program which overrides __builtin_clzll 2021-02-23 3:32 [Bug c/99211] New: gcc fails on program which overrides __builtin_clzll zhan3299 at purdue dot edu @ 2021-02-23 8:27 ` rguenth at gcc dot gnu.org 2021-02-23 9:08 ` jakub at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: rguenth at gcc dot gnu.org @ 2021-02-23 8:27 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99211 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |accepts-invalid, | |ice-on-invalid-code CC| |jsm28 at gcc dot gnu.org --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- I wonder if we can reject definitions/declarations of identifiers in GCCs implementation namespace (__builtin_*), even if correctly typed? The C family frontends have been prone to accept random crap as builtin functions. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/99211] gcc fails on program which overrides __builtin_clzll 2021-02-23 3:32 [Bug c/99211] New: gcc fails on program which overrides __builtin_clzll zhan3299 at purdue dot edu 2021-02-23 8:27 ` [Bug c/99211] " rguenth at gcc dot gnu.org @ 2021-02-23 9:08 ` jakub at gcc dot gnu.org 2021-02-23 10:29 ` redi at gcc dot gnu.org 2021-02-23 10:50 ` jakub at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: jakub at gcc dot gnu.org @ 2021-02-23 9:08 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99211 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- I think we have other PRs like this and it has been discussed. Problem with disabling altogether __builtin_* function declarations/definitions is that code in the wild uses typeof (whatever) __builtin_whatever __attribute__((...)); style declarations. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/99211] gcc fails on program which overrides __builtin_clzll 2021-02-23 3:32 [Bug c/99211] New: gcc fails on program which overrides __builtin_clzll zhan3299 at purdue dot edu 2021-02-23 8:27 ` [Bug c/99211] " rguenth at gcc dot gnu.org 2021-02-23 9:08 ` jakub at gcc dot gnu.org @ 2021-02-23 10:29 ` redi at gcc dot gnu.org 2021-02-23 10:50 ` jakub at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: redi at gcc dot gnu.org @ 2021-02-23 10:29 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99211 --- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #2) > Problem with disabling altogether __builtin_* function > declarations/definitions > is that code in the wild uses > typeof (whatever) __builtin_whatever __attribute__((...)); > style declarations. It deserves to be broken. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/99211] gcc fails on program which overrides __builtin_clzll 2021-02-23 3:32 [Bug c/99211] New: gcc fails on program which overrides __builtin_clzll zhan3299 at purdue dot edu ` (2 preceding siblings ...) 2021-02-23 10:29 ` redi at gcc dot gnu.org @ 2021-02-23 10:50 ` jakub at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: jakub at gcc dot gnu.org @ 2021-02-23 10:50 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99211 --- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- We have it even in gcc sources, though ifdefed so it won't trigger with recent-ish gcc: libstdc++-v3/include/ext/throw_allocator.h: __typeof__(&std::sprintf) __builtin_sprintf = &std::sprintf; I think this was PR32455, I believe the patch has never been applied, but I don't really remember all the details about it. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-02-23 10:50 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-02-23 3:32 [Bug c/99211] New: gcc fails on program which overrides __builtin_clzll zhan3299 at purdue dot edu 2021-02-23 8:27 ` [Bug c/99211] " rguenth at gcc dot gnu.org 2021-02-23 9:08 ` jakub at gcc dot gnu.org 2021-02-23 10:29 ` redi at gcc dot gnu.org 2021-02-23 10:50 ` jakub at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).