[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] [v2] x86: apic: avoid -Wshadow warning in header
- To: David Laight <David.Laight@xxxxxxxxxx>, 'Arvind Sankar' <nivedita@xxxxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>
- From: Paolo Bonzini <pbonzini@xxxxxxxxxx>
- Date: Fri, 30 Oct 2020 19:16:50 +0100
- Authentication-results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@xxxxxxxxxx
- Cc: 'Arnd Bergmann' <arnd@xxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, "x86@xxxxxxxxxx" <x86@xxxxxxxxxx>, Arnd Bergmann <arnd@xxxxxxxx>, "K. Y. Srinivasan" <kys@xxxxxxxxxxxxx>, Haiyang Zhang <haiyangz@xxxxxxxxxxxxx>, Stephen Hemminger <sthemmin@xxxxxxxxxxxxx>, "H. Peter Anvin" <hpa@xxxxxxxxx>, "Rafael J. Wysocki" <rjw@xxxxxxxxxxxxx>, Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>, Wanpeng Li <wanpengli@xxxxxxxxxxx>, Jim Mattson <jmattson@xxxxxxxxxx>, Joerg Roedel <joro@xxxxxxxxxx>, "linux-hyperv@xxxxxxxxxxxxxxx" <linux-hyperv@xxxxxxxxxxxxxxx>, "linux-kernel@xxxxxxxxxxxxxxx" <linux-kernel@xxxxxxxxxxxxxxx>, "kvm@xxxxxxxxxxxxxxx" <kvm@xxxxxxxxxxxxxxx>, "platform-driver-x86@xxxxxxxxxxxxxxx" <platform-driver-x86@xxxxxxxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "iommu@xxxxxxxxxxxxxxxxxxxxxxxxxx" <iommu@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Delivery-date: Fri, 30 Oct 2020 18:17:18 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 29/10/20 23:12, David Laight wrote:
>> https://godbolt.org/z/4dzPbM
>>
>> With -fno-strict-aliasing, the compiler reloads the pointer if you write
>> to the start of what it points to, but not if you write to later
>> elements.
> I guess it assumes that global data doesn't overlap.
Yeah, setting
p = (struct s *) ((char *)&p) - 8;
invokes undefined behavior _for a different reason than strict aliasing_
(it's a pointer that is based on "p" but points before its start or
after one byte past its end). So the compiler assumes that only the
first few bytes of a global can overlap it.
If you change the size of the fields from long to char in the compiler
explorer link above, every field forces a reload of the global.
Paolo
|