This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] pedantic warning behavior when casting void* to ptr-to-func, 4.8 and 4.9
- From: Daniel Gutson <daniel dot gutson at tallertechnologies dot com>
- To: Daniel Gutson <daniel dot gutson at tallertechnologies dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>, rdsandiford at googlemail dot com
- Date: Tue, 22 Apr 2014 09:15:25 -0300
- Subject: Re: [PATCH] pedantic warning behavior when casting void* to ptr-to-func, 4.8 and 4.9
- Authentication-results: sourceware.org; auth=none
- References: <CAF5HaEVzxmXnzEuW6ZCDXxTu=apqWZNM+ggoUFDQpNvun91MEw at mail dot gmail dot com> <CAF5HaEXFhJrx2KC+8WXL2L4apm6qDt2WQmJTFeGVH138UTfQdg at mail dot gmail dot com> <CAF5HaEU01=Bqj4cL20pohS+14Qmvbr0=CgMWeWCBXTgLxO1obw at mail dot gmail dot com> <87k3aqjo0j dot fsf at talisman dot default> <CAF5HaEXZy8U=dFmzLy4iVnMFXJ1=QT6N_Sk5Qix3jb2XB+wq1Q at mail dot gmail dot com>
Ping for maintainer please.
Thanks,
Daniel.
On Tue, Apr 15, 2014 at 7:05 PM, Daniel Gutson
<daniel.gutson@tallertechnologies.com> wrote:
> On Tue, Apr 15, 2014 at 6:12 PM, Richard Sandiford
> <rdsandiford@googlemail.com> wrote:
>> cc:ing Jason, who's the C++ maintainer.
>
>
> FWIW: I created http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60850
>
>>
>> Daniel Gutson <daniel.gutson@tallertechnologies.com> writes:
>>> ping for maintainer.
>>>
>>> Could this be considered for 4.8.3 please?
>>>
>>> Thanks,
>>>
>>> Daniel.
>>>
>>>
>>> On Tue, Apr 1, 2014 at 2:46 PM, Daniel Gutson
>>> <daniel.gutson@tallertechnologies.com> wrote:
>>>>
>>>> I just realized I posted the patch in the wrong list.
>>>>
>>>>
>>>> ---------- Forwarded message ----------
>>>> From: Daniel Gutson <daniel.gutson@tallertechnologies.com>
>>>> Date: Tue, Apr 1, 2014 at 10:43 AM
>>>> Subject: [PATCH] pedantic warning behavior when casting void* to
>>>> ptr-to-func, 4.8 and 4.9
>>>> To: gcc Mailing List <gcc@gcc.gnu.org>
>>>>
>>>>
>>>> Hi,
>>>>
>>>> I observed two different behaviors in gcc 4.8.2 and 4.9 regarding
>>>> the same issue, IMO both erroneous.
>>>>
>>>> Regarding 4.8.2, #pragma GCC diagnostic ignored "-pedantic" doesn't
>>>> work in cases such as:
>>>> void* p = 0;
>>>> #pragma GCC diagnostic ignored "-pedantic"
>>>> F* f2 = reinterpret_cast<F*>(p);
>>>>
>>>> (see testcase in the patch).
>>>>
>>>> The attached patch attempts to fix this issue. Since I no longer have
>>>> write access, please
>>>> apply this for me if correct (is the 4.8 branch still alive for adding fixes?).
>>>>
>>>> Regarding 4.9, gcc fails to complain at all when -pedantic is passed,
>>>> even specifying -std=c++03.
>>>> Please let me know if this is truly a bug, in which case I could also
>>>> fix it for the latest version as well
>>>> (if so, please let me know if I should look into trunk or any other branch).
>>>>
>>>> Thanks,
>>>>
>>>> Daniel.
>>>>
>>>> 2014-03-31 Daniel Gutson <daniel.gutson@tallertechnologies.com>
>>>>
>>>> gcc/cp/
>>>> * typeck.c (build_reinterpret_cast_1): Pass proper argument to
>>>> warn() in pedantic.
>>>>
>>>> gcc/testsuite/g++.dg/
>>>> * diagnostic/pedantic.C: New test case.
>>
>> --- gcc-4.8.2-orig/gcc/cp/typeck.c 2014-03-31 22:29:42.736367936 -0300
>> +++ gcc-4.8.2/gcc/cp/typeck.c 2014-03-31 14:26:43.536747050 -0300
>> @@ -6639,7 +6639,7 @@
>> where possible, and it is necessary in some cases. DR 195
>> addresses this issue, but as of 2004/10/26 is still in
>> drafting. */
>> - warning (0, "ISO C++ forbids casting between pointer-to-function and pointer-to-object");
>> + warning (OPT_Wpedantic, "ISO C++ forbids casting between pointer-to-function and pointer-to-object");
>> return fold_if_not_in_template (build_nop (type, expr));
>> }
>> else if (TREE_CODE (type) == VECTOR_TYPE)
>> --- gcc-4.8.2-orig/gcc/testsuite/g++.dg/diagnostic/pedantic.C 1969-12-31 21:00:00.000000000 -0300
>> +++ gcc-4.8.2/gcc/testsuite/g++.dg/diagnostic/pedantic.C 2014-03-31 17:24:42.532607344 -0300
>> @@ -0,0 +1,12 @@
>> +// { dg-do compile }
>> +// { dg-options "-pedantic" }
>> +typedef void F(void);
>> +
>> +void foo()
>> +{
>> + void* p = 0;
>> + F* f1 = reinterpret_cast<F*>(p); // { dg-warning "ISO" }
>> +#pragma GCC diagnostic ignored "-pedantic"
>> + F* f2 = reinterpret_cast<F*>(p);
>> +}
>> +
>
>
>
> --
>
> Daniel F. Gutson
> Chief Engineering Officer, SPD
>
>
> San Lorenzo 47, 3rd Floor, Office 5
>
> CÃrdoba, Argentina
>
>
> Phone: +54 351 4217888 / +54 351 4218211
>
> Skype: dgutson
--
Daniel F. Gutson
Chief Engineering Officer, SPD
San Lorenzo 47, 3rd Floor, Office 5
CÃrdoba, Argentina
Phone: +54 351 4217888 / +54 351 4218211
Skype: dgutson