This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFC: [PATCH] Add warn_if_not_aligned attribute
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Szabolcs Nagy <szabolcs dot nagy at arm dot com>
- Cc: Joseph Myers <joseph at codesourcery dot com>, nd <nd at arm dot com>, Martin Sebor <msebor at gmail dot com>, Jason Merrill <jason at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 21 Aug 2017 05:37:58 -0700
- Subject: Re: RFC: [PATCH] Add warn_if_not_aligned attribute
- Authentication-results: sourceware.org; auth=none
- References: <6c6c268d-a40b-cfa9-574c-ad235f9205b7@gmail.com> <CAMe9rOqR6w+vy+3d045cACetg9ZW706naBD-FtVdCOmgj+Dv-g@mail.gmail.com> <CAMe9rOo0WL+1rJQ_3EMdi2wJq-KJ4YWmTmGodeoVZ5e10vV-pA@mail.gmail.com> <4a4ac20f-9c27-4844-55dc-38ff56ac138b@gmail.com> <CAMe9rOryx5NH9Tp6Y26f=h5pWPeg9kNyOBxuhTjT=aOJxvDYcA@mail.gmail.com> <ea1100d5-fe57-fe31-134c-6dcf94289437@gmail.com> <CAMe9rOp-X1S_HY70hr_-CO2HDvsDAJEw1FTMEj+CKS5Ds7C8-A@mail.gmail.com> <alpine.DEB.2.20.1706151728020.3768@digraph.polyomino.org.uk> <20170616115455.GA3457@gmail.com> <alpine.DEB.2.20.1707061537330.7309@digraph.polyomino.org.uk> <20170708134504.GA1303@gmail.com> <alpine.DEB.2.20.1708171345400.20976@digraph.polyomino.org.uk> <CAMe9rOo6GSf3JycjWwkhD1iQVa5z-duwXAqu-3Q8gDzCfW8gzg@mail.gmail.com> <599ABD0B.2000603@arm.com>
On Mon, Aug 21, 2017 at 3:59 AM, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
> On 17/08/17 15:56, H.J. Lu wrote:
>> On Thu, Aug 17, 2017 at 6:52 AM, Joseph Myers <joseph@codesourcery.com> wrote:
>>> On Sat, 8 Jul 2017, H.J. Lu wrote:
>>>
>>>> +@item -Wpacked-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
>>>> +@opindex Wpacked-not-aligned
>>>> +@opindex Wno-packed-not-aligned
>>>> +Warn if a structure field with explicitly specified alignment in a
>>>> +packed struct or union is misaligned. For example, a warning will
>>>> +be issued on @code{struct S}, like, @code{warning: alignment 1 of
>>>> +'struct S' is less than 8}, in this code:
>>>
>>> Use @samp for warnings quoted in the manual, as previously discussed.
>>>
>>> OK with that change, in the absence of C++ maintainer objections within 48
>>> hours.
>>>
>>
>> Here is the updated patch. I moved c++ changes to merge_decls, where
>> alignment is merged, and check_bitfield_type_and_width, where bit-fields
>> are checked.
>>
>> Tested on x86-64 and i686.
>>
>
> i assume packed semantics is same on arm so these
> should warn on arm too ?
>
> on arm i see:
>
> FAIL: gcc.dg/pr53037-2.c (test for warnings, line 8)
> FAIL: gcc.dg/pr53037-2.c (test for warnings, line 16)
> FAIL: gcc.dg/pr53037-2.c (test for warnings, line 32)
> FAIL: gcc.dg/pr53037-3.c (test for warnings, line 8)
> FAIL: gcc.dg/pr53037-3.c (test for warnings, line 16)
> FAIL: gcc.dg/pr53037-3.c (test for warnings, line 32)
>
> FAIL: g++.dg/pr53037-2.C -std=gnu++98 (test for warnings, line 6)
> FAIL: g++.dg/pr53037-2.C -std=gnu++98 (test for warnings, line 16)
> FAIL: g++.dg/pr53037-2.C -std=gnu++98 (test for warnings, line 29)
> FAIL: g++.dg/pr53037-2.C -std=gnu++11 (test for warnings, line 6)
> FAIL: g++.dg/pr53037-2.C -std=gnu++11 (test for warnings, line 16)
> FAIL: g++.dg/pr53037-2.C -std=gnu++11 (test for warnings, line 29)
> FAIL: g++.dg/pr53037-2.C -std=gnu++14 (test for warnings, line 6)
> FAIL: g++.dg/pr53037-2.C -std=gnu++14 (test for warnings, line 16)
> FAIL: g++.dg/pr53037-2.C -std=gnu++14 (test for warnings, line 29)
> FAIL: g++.dg/pr53037-3.C -std=gnu++98 (test for warnings, line 6)
> FAIL: g++.dg/pr53037-3.C -std=gnu++98 (test for warnings, line 16)
> FAIL: g++.dg/pr53037-3.C -std=gnu++98 (test for warnings, line 29)
> FAIL: g++.dg/pr53037-3.C -std=gnu++11 (test for warnings, line 6)
> FAIL: g++.dg/pr53037-3.C -std=gnu++11 (test for warnings, line 16)
> FAIL: g++.dg/pr53037-3.C -std=gnu++11 (test for warnings, line 29)
> FAIL: g++.dg/pr53037-3.C -std=gnu++14 (test for warnings, line 6)
> FAIL: g++.dg/pr53037-3.C -std=gnu++14 (test for warnings, line 16)
> FAIL: g++.dg/pr53037-3.C -std=gnu++14 (test for warnings, line 29)
>
See:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53037#c29
--
H.J.