public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99975] New: wrong variable alignment on a locally redeclared overaligned extern variable
@ 2021-04-08 16:13 msebor at gcc dot gnu.org
2021-04-08 16:30 ` [Bug c++/99975] " msebor at gcc dot gnu.org
2024-09-19 5:38 ` pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-04-08 16:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99975
Bug ID: 99975
Summary: wrong variable alignment on a locally redeclared
overaligned extern variable
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
Perhaps due to the same underlying bug as pr99974, the C++ front end determines
the wrong alignment from an overaligned extern variable redeclared locally
without the alignment attribute.
Both the C front end as well as other compilers (Clang and ICC) behave
correctly and determine the same alignment in both functions.
$ cat z.C && /build/gcc-master/gcc/xgcc -B /build/gcc-master/gcc -O -S -Wall
-fdump-tree-optimized=/dev/stdout z.C
extern __attribute__ ((aligned (32))) int i;
int fa32 ()
{
return __alignof__ (i); // folded to 32 (good)
}
int ga32 ()
{
extern int i;
return __alignof__ (i); // folded to 4 (bug)
}
;; Function fa32 (_Z4fa32v, funcdef_no=0, decl_uid=2347, cgraph_uid=1,
symbol_order=0)
int fa32 ()
{
<bb 2> [local count: 1073741824]:
return 32;
}
;; Function ga32 (_Z4ga32v, funcdef_no=1, decl_uid=2349, cgraph_uid=2,
symbol_order=1)
int ga32 ()
{
<bb 2> [local count: 1073741824]:
return 4;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/99975] wrong variable alignment on a locally redeclared overaligned extern variable
2021-04-08 16:13 [Bug c++/99975] New: wrong variable alignment on a locally redeclared overaligned extern variable msebor at gcc dot gnu.org
@ 2021-04-08 16:30 ` msebor at gcc dot gnu.org
2024-09-19 5:38 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-04-08 16:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99975
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Surprisingly, other variable attributes such as deprecated and alloc_size (the
latter applied to a pointer to a function) do work as expected:
$ cat z.C && gcc -S -Wall z.C
int f ()
{
extern __attribute__ ((deprecated ("I was deprecated in f()"))) int i;
return i;
}
int gv()
{
extern int i;
return i;
}
z.C: In function ‘int f()’:
z.C:5:10: warning: ‘i’ is deprecated: I was deprecated in f()
[-Wdeprecated-declarations]
5 | return i;
| ^
z.C:3:71: note: declared here
3 | extern __attribute__ ((deprecated ("I was deprecated in f()"))) int i;
| ^
z.C: In function ‘int gv()’:
z.C:12:10: warning: ‘i’ is deprecated: I was deprecated in f()
[-Wdeprecated-declarations]
12 | return i;
| ^
z.C:3:71: note: declared here
3 | extern __attribute__ ((deprecated ("I was deprecated in f()"))) int i;
| ^
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/99975] wrong variable alignment on a locally redeclared overaligned extern variable
2021-04-08 16:13 [Bug c++/99975] New: wrong variable alignment on a locally redeclared overaligned extern variable msebor at gcc dot gnu.org
2021-04-08 16:30 ` [Bug c++/99975] " msebor at gcc dot gnu.org
@ 2024-09-19 5:38 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-09-19 5:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99975
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2024-09-19
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-09-19 5:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-08 16:13 [Bug c++/99975] New: wrong variable alignment on a locally redeclared overaligned extern variable msebor at gcc dot gnu.org
2021-04-08 16:30 ` [Bug c++/99975] " msebor at gcc dot gnu.org
2024-09-19 5:38 ` pinskia 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).