public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/46859] New: Attribute depends on location
@ 2010-12-09 0:28 hjl.tools at gmail dot com
2010-12-09 15:44 ` [Bug c/46859] " hjl.tools at gmail dot com
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: hjl.tools at gmail dot com @ 2010-12-09 0:28 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46859
Summary: Attribute depends on location
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: hjl.tools@gmail.com
foo2 in this test isn't aligned:
[hjl@gnu-6 pages-1]$ cat a.c
__attribute__((aligned(4096)))
int *
foo1 ()
{
return 0;
}
int *
__attribute__((aligned(4096)))
foo2 ()
{
return 0;
}
__attribute__((aligned(4096)))
int
foo3 ()
{
return 0;
}
int
__attribute__((aligned(4096)))
foo4 ()
{
return 0;
}
[hjl@gnu-6 pages-1]$ gcc -S -O2 a.c
[hjl@gnu-6 pages-1]$ cat a.s
.file "a.c"
.text
.align 4096
.globl foo1
.type foo1, @function
foo1:
.LFB0:
.cfi_startproc
xorl %eax, %eax
ret
.cfi_endproc
.LFE0:
.size foo1, .-foo1
.p2align 4,,15
.globl foo2
.type foo2, @function
foo2:
.LFB1:
.cfi_startproc
xorl %eax, %eax
ret
.cfi_endproc
.LFE1:
.size foo2, .-foo2
.align 4096
.globl foo3
.type foo3, @function
foo3:
.LFB2:
.cfi_startproc
xorl %eax, %eax
ret
.cfi_endproc
.LFE2:
.size foo3, .-foo3
.align 4096
.globl foo4
.type foo4, @function
foo4:
.LFB3:
.cfi_startproc
xorl %eax, %eax
ret
.cfi_endproc
.LFE3:
.size foo4, .-foo4
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/46859] Attribute depends on location
2010-12-09 0:28 [Bug c/46859] New: Attribute depends on location hjl.tools at gmail dot com
@ 2010-12-09 15:44 ` hjl.tools at gmail dot com
2010-12-09 20:31 ` davek at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: hjl.tools at gmail dot com @ 2010-12-09 15:44 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46859
--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> 2010-12-09 15:44:49 UTC ---
Shouldn't foo1/foo2 have the same alignment?
[hjl@gnu-6 pages-1]$ cat x.c
typedef int * ptr_t;
ptr_t
__attribute__((aligned(4096)))
foo1 ()
{
return 0;
}
int *
__attribute__((aligned(4096)))
foo2 ()
{
return 0;
}
[hjl@gnu-6 pages-1]$ gcc -S x.c
[hjl@gnu-6 pages-1]$ cat x.s
.file "x.c"
.text
.align 4096
.globl foo1
.type foo1, @function
foo1:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl $0, %eax
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size foo1, .-foo1
.globl foo2
.type foo2, @function
foo2:
.LFB1:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl $0, %eax
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE1:
.size foo2, .-foo2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/46859] Attribute depends on location
2010-12-09 0:28 [Bug c/46859] New: Attribute depends on location hjl.tools at gmail dot com
2010-12-09 15:44 ` [Bug c/46859] " hjl.tools at gmail dot com
@ 2010-12-09 20:31 ` davek at gcc dot gnu.org
2010-12-09 20:45 ` hjl.tools at gmail dot com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: davek at gcc dot gnu.org @ 2010-12-09 20:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46859
Dave Korn <davek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |davek at gcc dot gnu.org
--- Comment #2 from Dave Korn <davek at gcc dot gnu.org> 2010-12-09 20:31:25 UTC ---
I note that if you re-write foo2 like this:
int
__attribute__((aligned(4096)))
*
foo2a ()
{
return 0;
}
it gets aligned properly. I think something must be going wrong when the
parser starts to build a derived pointer type based on the underlying scalar
type, but that's just a first guess.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/46859] Attribute depends on location
2010-12-09 0:28 [Bug c/46859] New: Attribute depends on location hjl.tools at gmail dot com
2010-12-09 15:44 ` [Bug c/46859] " hjl.tools at gmail dot com
2010-12-09 20:31 ` davek at gcc dot gnu.org
@ 2010-12-09 20:45 ` hjl.tools at gmail dot com
2010-12-09 21:06 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: hjl.tools at gmail dot com @ 2010-12-09 20:45 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46859
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jsm28 at gcc dot gnu.org
--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> 2010-12-09 20:45:46 UTC ---
For
int *
__attribute__((aligned(4096)))
foo2 ()
{
return 0;
}
parser applies attribute to "int *" instead of foo2.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/46859] Attribute depends on location
2010-12-09 0:28 [Bug c/46859] New: Attribute depends on location hjl.tools at gmail dot com
` (2 preceding siblings ...)
2010-12-09 20:45 ` hjl.tools at gmail dot com
@ 2010-12-09 21:06 ` pinskia at gcc dot gnu.org
2010-12-09 21:07 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2010-12-09 21:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46859
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> 2010-12-09 21:06:38 UTC ---
I think this is the correct behavior which is also documented this way too.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/46859] Attribute depends on location
2010-12-09 0:28 [Bug c/46859] New: Attribute depends on location hjl.tools at gmail dot com
` (3 preceding siblings ...)
2010-12-09 21:06 ` pinskia at gcc dot gnu.org
@ 2010-12-09 21:07 ` pinskia at gcc dot gnu.org
2010-12-09 21:24 ` joseph at codesourcery dot com
2013-10-21 20:08 ` mpolacek at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2010-12-09 21:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46859
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> 2010-12-09 21:07:15 UTC ---
This is also why it is almost always better to put the attribute on the
declaration rather than the definition.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/46859] Attribute depends on location
2010-12-09 0:28 [Bug c/46859] New: Attribute depends on location hjl.tools at gmail dot com
` (4 preceding siblings ...)
2010-12-09 21:07 ` pinskia at gcc dot gnu.org
@ 2010-12-09 21:24 ` joseph at codesourcery dot com
2013-10-21 20:08 ` mpolacek at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: joseph at codesourcery dot com @ 2010-12-09 21:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46859
--- Comment #6 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2010-12-09 21:23:53 UTC ---
On Thu, 9 Dec 2010, hjl.tools at gmail dot com wrote:
> For
>
> int *
> __attribute__((aligned(4096)))
> foo2 ()
> {
> return 0;
> }
>
> parser applies attribute to "int *" instead of foo2.
Yes, this is as documented, just like if you had a type qualifier there.
I see that two critical words were missing in the relevant section of the
manual; I've applied this patch to add them.
Index: doc/extend.texi
===================================================================
--- doc/extend.texi (revision 167663)
+++ doc/extend.texi (working copy)
@@ -4036,7 +4036,7 @@
declaration @code{T D} specifies the type
``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
@code{T D1} specifies the type ``@var{derived-declarator-type-list}
-@var{type-qualifier-and-attribute-specifier-list} @var{Type}'' for
+@var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
@var{ident}.
For example,
Index: ChangeLog
===================================================================
--- ChangeLog (revision 167663)
+++ ChangeLog (working copy)
@@ -1,5 +1,10 @@
2010-12-09 Joseph Myers <joseph@codesourcery.com>
+ * doc/extend.texi (Attribute Syntax): Correct description of
+ attributes in pointer declarators.
+
+2010-12-09 Joseph Myers <joseph@codesourcery.com>
+
* config/mips/vxworks.h (DBX_REGISTER_NUMBER): Undefine.
* config.gcc (mips64*-*-linux* | mipsisa64*-*-linux*,
mips*-*-linux*, mips-wrs-vxworks): Don't use svr4.h.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/46859] Attribute depends on location
2010-12-09 0:28 [Bug c/46859] New: Attribute depends on location hjl.tools at gmail dot com
` (5 preceding siblings ...)
2010-12-09 21:24 ` joseph at codesourcery dot com
@ 2013-10-21 20:08 ` mpolacek at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-10-21 20:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46859
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |mpolacek at gcc dot gnu.org
Resolution|--- |FIXED
--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
So nothing more to do here.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-10-21 20:08 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-09 0:28 [Bug c/46859] New: Attribute depends on location hjl.tools at gmail dot com
2010-12-09 15:44 ` [Bug c/46859] " hjl.tools at gmail dot com
2010-12-09 20:31 ` davek at gcc dot gnu.org
2010-12-09 20:45 ` hjl.tools at gmail dot com
2010-12-09 21:06 ` pinskia at gcc dot gnu.org
2010-12-09 21:07 ` pinskia at gcc dot gnu.org
2010-12-09 21:24 ` joseph at codesourcery dot com
2013-10-21 20:08 ` mpolacek 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).