This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCHv2] Add a warning for invalid function casts
- 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>, Jeff Law <law at redhat 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>
- Date: Thu, 30 Nov 2017 10:45:15 -0500
- Subject: Re: [PATCHv2] Add a warning for invalid function casts
- Authentication-results: sourceware.org; auth=none
- References: <AM5PR0701MB265700BCFDF7620223717DCCE4720@AM5PR0701MB2657.eurprd07.prod.outlook.com> <1644e85e-6d3a-a114-32b5-a9b49de24407@gmail.com> <AM5PR0701MB2657ABAE3C4B6BC3EF64F923E4710@AM5PR0701MB2657.eurprd07.prod.outlook.com> <72167c17-48f5-d5d6-d9cd-87004e3c1d11@gmail.com> <f22cfd49-127e-e1d4-442e-e619807511f6@redhat.com> <476f5e91-3768-ef69-331a-ce0c00d38277@hotmail.de> <6f4b4385-52af-6b41-14bf-7e0a06895a8f@hotmail.de> <43dcb212-0c40-f55c-61a0-84a5c149695e@gmail.com> <AM5PR0701MB2657697940DE7A81A479CF20E4740@AM5PR0701MB2657.eurprd07.prod.outlook.com> <4abe4931-7cee-81d2-1019-6834006d396e@gmail.com> <AM5PR0701MB265758B1D2D4F227716BA923E4740@AM5PR0701MB2657.eurprd07.prod.outlook.com> <87146b27-e57b-0f0d-bd14-53a2c2acd67c@redhat.com> <40891950-f967-1ce6-3cc9-8595cde9a133@hotmail.de>
On Thu, Nov 30, 2017 at 10:14 AM, Bernd Edlinger
<bernd.edlinger@hotmail.de> wrote:
> On 11/29/17 22:57, Jason Merrill wrote:
>> On 10/09/2017 06:30 PM, Bernd Edlinger wrote:
>>> + if (INTEGRAL_TYPE_P (t1)
>>> + && INTEGRAL_TYPE_P (t2)
>>> + && TYPE_PRECISION (t1) == TYPE_PRECISION (t2)
>>> + && (TYPE_UNSIGNED (t1) == TYPE_UNSIGNED (t2)
>>> + || TYPE_PRECISION (t1) >= TYPE_PRECISION (integer_type_node)))
>>> + return true;
>>
>> This section needs a comment explaining what you're allowing and why.
>
> Okay. I will add a comment here:
>
> /* The signedness of the parameter matters only when an integral
> type smaller than int is promoted to int, otherwise only the
> precision of the parameter matters.
> This check should make sure that the callee does not see
> undefined values in argument registers. */
If we're thinking about argument promotion, should this use
type_passed_as rather than assume promotion to int?
Jason