[Bug ipa/67051] symtab_node::equal_address_to too conservative?

2022-01-05 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67051

Andrew Pinski  changed:

   What|Removed |Added

   Severity|normal  |enhancement
 Ever confirmed|0   |1
   Last reconfirmed||2022-01-06
 Status|UNCONFIRMED |NEW

--- Comment #1 from Andrew Pinski  ---
Confirmed testcase:

int i;
int j;

int f(void)
{
return &i != &j;
}

Compile with -O2 -fcommon and you will see the problem. Note this might be less
important now that -fno-common is the default.

[Bug ipa/67051] symtab_node::equal_address_to too conservative?

2024-06-04 Thread hubicka at gcc dot gnu.org via Gcc-bugs
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.