* Using [[may_alias]] in C23/C++23 on a union works in neither post-"union" position, or at the end of the definition
@ 2022-12-06 3:17 Gavin Ray
2022-12-06 16:54 ` Joseph Myers
0 siblings, 1 reply; 6+ messages in thread
From: Gavin Ray @ 2022-12-06 3:17 UTC (permalink / raw)
To: gcc
[-- Attachment #1: Type: text/plain, Size: 524 bytes --]
The reproduction is below. Not sure if this is intended or a bug, sorry to
clutter up the mailing list if it's intended!
union __attribute__((may_alias)) works {};
// <source>:3:18: note: attribute for 'union broken2' must follow the
'union' keyword
union broken1 {} [[may_alias]];
// Okay, so let's move it so it follows union...
// <source>:7:21: warning: 'may_alias' attribute directive ignored
[-Wattributes]
// 7 | union [[may_alias]] broken2 {};
// | ^~~~~~~
union [[may_alias]] broken2 {};
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Using [[may_alias]] in C23/C++23 on a union works in neither post-"union" position, or at the end of the definition
2022-12-06 3:17 Using [[may_alias]] in C23/C++23 on a union works in neither post-"union" position, or at the end of the definition Gavin Ray
@ 2022-12-06 16:54 ` Joseph Myers
2022-12-06 18:35 ` Gavin Ray
0 siblings, 1 reply; 6+ messages in thread
From: Joseph Myers @ 2022-12-06 16:54 UTC (permalink / raw)
To: Gavin Ray; +Cc: gcc
On Mon, 5 Dec 2022, Gavin Ray via Gcc wrote:
> union [[may_alias]] broken2 {};
With [[]] syntax it's [[gnu::may_alias]], since it's not a standard
attribute.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Using [[may_alias]] in C23/C++23 on a union works in neither post-"union" position, or at the end of the definition
2022-12-06 16:54 ` Joseph Myers
@ 2022-12-06 18:35 ` Gavin Ray
2022-12-06 19:23 ` Jonathan Wakely
0 siblings, 1 reply; 6+ messages in thread
From: Gavin Ray @ 2022-12-06 18:35 UTC (permalink / raw)
To: Joseph Myers; +Cc: gcc
[-- Attachment #1: Type: text/plain, Size: 587 bytes --]
Oh, D'oh! Thanks Joseph, apologies for the needless email on the list then.
One final question if I could -- does that mean that in order to support
"may-alias" with the bracket syntax on both Clang and GCC, it would require:
union [[gnu::may_alias]] [[clang::may_alias]] foo {};
On Tue, Dec 6, 2022 at 11:54 AM Joseph Myers <joseph@codesourcery.com>
wrote:
> On Mon, 5 Dec 2022, Gavin Ray via Gcc wrote:
>
> > union [[may_alias]] broken2 {};
>
> With [[]] syntax it's [[gnu::may_alias]], since it's not a standard
> attribute.
>
> --
> Joseph S. Myers
> joseph@codesourcery.com
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Using [[may_alias]] in C23/C++23 on a union works in neither post-"union" position, or at the end of the definition
2022-12-06 18:35 ` Gavin Ray
@ 2022-12-06 19:23 ` Jonathan Wakely
2022-12-06 20:31 ` Gavin Ray
0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Wakely @ 2022-12-06 19:23 UTC (permalink / raw)
To: Gavin Ray; +Cc: Joseph Myers, gcc
[-- Attachment #1: Type: text/plain, Size: 460 bytes --]
On Tue, 6 Dec 2022, 18:36 Gavin Ray via Gcc, <gcc@gcc.gnu.org> wrote:
> Oh, D'oh! Thanks Joseph, apologies for the needless email on the list then.
>
> One final question if I could -- does that mean that in order to support
> "may-alias" with the bracket syntax on both Clang and GCC, it would
> require:
>
> union [[gnu::may_alias]] [[clang::may_alias]] foo {};
>
Probably not. Clang accepts the gnu:: namespace for attributes that
originated with GCC.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Using [[may_alias]] in C23/C++23 on a union works in neither post-"union" position, or at the end of the definition
2022-12-06 19:23 ` Jonathan Wakely
@ 2022-12-06 20:31 ` Gavin Ray
2022-12-06 20:36 ` Jonathan Wakely
0 siblings, 1 reply; 6+ messages in thread
From: Gavin Ray @ 2022-12-06 20:31 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: Joseph Myers, gcc
[-- Attachment #1: Type: text/plain, Size: 673 bytes --]
Ah got it, didn't know that (handy, will save me duplicating a bunch of
attributes).
Thanks Jonathan!
On Tue, Dec 6, 2022 at 2:23 PM Jonathan Wakely <jwakely.gcc@gmail.com>
wrote:
>
>
> On Tue, 6 Dec 2022, 18:36 Gavin Ray via Gcc, <gcc@gcc.gnu.org> wrote:
>
>> Oh, D'oh! Thanks Joseph, apologies for the needless email on the list
>> then.
>>
>> One final question if I could -- does that mean that in order to support
>> "may-alias" with the bracket syntax on both Clang and GCC, it would
>> require:
>>
>> union [[gnu::may_alias]] [[clang::may_alias]] foo {};
>>
>
>
>
> Probably not. Clang accepts the gnu:: namespace for attributes that
> originated with GCC.
>
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Using [[may_alias]] in C23/C++23 on a union works in neither post-"union" position, or at the end of the definition
2022-12-06 20:31 ` Gavin Ray
@ 2022-12-06 20:36 ` Jonathan Wakely
0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Wakely @ 2022-12-06 20:36 UTC (permalink / raw)
To: Gavin Ray; +Cc: Joseph Myers, gcc
On Tue, 6 Dec 2022 at 20:32, Gavin Ray wrote:
>
> Ah got it, didn't know that (handy, will save me duplicating a bunch of attributes).
> Thanks Jonathan!
The Clang doc acually show all the forms that can be used for each attribute:
https://clang.llvm.org/docs/AttributeReference.html#may-alias
"GNU" means __attribute__((may_alias)) and the C++11 and C2x columns
show that [[gnu::may_alias]] is the right way to use it.
Clang-specific attributes use clang:: instead e.g.
https://clang.llvm.org/docs/AttributeReference.html#preserve-all
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-12-06 20:37 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-06 3:17 Using [[may_alias]] in C23/C++23 on a union works in neither post-"union" position, or at the end of the definition Gavin Ray
2022-12-06 16:54 ` Joseph Myers
2022-12-06 18:35 ` Gavin Ray
2022-12-06 19:23 ` Jonathan Wakely
2022-12-06 20:31 ` Gavin Ray
2022-12-06 20:36 ` Jonathan Wakely
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).