This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Implement a warning for bogus sizeof(pointer) / sizeof(pointer[0])
- From: Jason Merrill <jason at redhat dot com>
- To: Bernd Edlinger <bernd dot edlinger at hotmail dot de>
- Cc: Martin Sebor <msebor at gmail dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Joseph Myers <joseph at codesourcery dot com>, Jeff Law <law at redhat dot com>, Richard Biener <rguenther at suse dot de>, Jakub Jelinek <jakub at redhat dot com>
- Date: Mon, 1 May 2017 11:54:21 -0400
- Subject: Re: [PATCH] Implement a warning for bogus sizeof(pointer) / sizeof(pointer[0])
- Authentication-results: sourceware.org; auth=none
- References: <AM4PR0701MB2162D22EC7A12EB0797E231DE41B0@AM4PR0701MB2162.eurprd07.prod.outlook.com> <776bb206-7b8e-1878-5411-3f1cdaabac05@gmail.com> <HE1PR0701MB2169D85858BE3B158B4CD3DBE41D0@HE1PR0701MB2169.eurprd07.prod.outlook.com> <20432ae0-2c58-42a0-cc71-dd128187af45@gmail.com> <AM4PR0701MB2162E9E0B096CBC57645F05CE4130@AM4PR0701MB2162.eurprd07.prod.outlook.com> <c2630692-a843-4396-3c78-12149bf284c4@gmail.com> <AM4PR0701MB216244DC6B64C2EA6C282103E4130@AM4PR0701MB2162.eurprd07.prod.outlook.com>
On Fri, Apr 28, 2017 at 1:05 PM, Bernd Edlinger
<bernd.edlinger@hotmail.de> wrote:
> On 04/28/17 17:29, Martin Sebor wrote:
>> On 04/28/2017 08:12 AM, Bernd Edlinger wrote:
>>>
>>> Do you want me to change the %qT format strings to %T ?
>>
>> Yes, with the surrounding %< and %> the nested directives should
>> use the unquoted forms, otherwise the printer would end up quoting
>> both the whole expression and the type operand.
>>
>> FWIW, to help avoid this mistake, I think this might be something
>> for GCC -Wformat to warn on and the pretty-printer to detect (and
>> ICE on).
>>
>
> Ah, now I understand. That's pretty advanced.
>
> Here is the modified patch with correct quoting of the expression.
>
> Bootstrap and reg-testing on x86_64-pc-linux-gnu.
> * cp-gimplify.c (cp_fold): Implement the -Wsizeof_pointer_div warning.
I think this warning belongs in cp_build_binary_op rather than cp_fold.
Jason