https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67051
--- Comment #2 from Jan Hubicka ---
I believe that there was some discussion on this in the past. I would be quite
happy to change the predicate to be more aggressive. Current code basically
duplicates what original fold-const.c did.
One problem is that we have no way to declare in header that one symbol is
alias of another while being defined in other translation unit.
jan@localhost:/tmp> cat t.c
extern int a;
extern int b __attribute ((alias("a")));
jan@localhost:/tmp> gcc t.c
t.c:2:12: error: ‘b’ aliased to undefined symbol ‘a’
2 | extern int b __attribute ((alias("a")));
|^
jan@localhost:/tmp> clang t.c
t.c:2:28: error: alias must point to a defined variable or function
2 | extern int b __attribute ((alias("a")));
|^
t.c:2:28: note: the function or variable specified in an alias must refer to
its mangled name
1 error generated.
So if one wants to use aliases intentionally (to do something smart about
superposing) then basically only valid testcases would be if translation units
never use both names together.
Also folding is done early when alias may not be declared yet, but that can be
solved by check for symtab state.