[PATCH INSTALLED]: Fix -Wc++-compat warnings in toplevel [t-z]*.c files

Gabriel Dos Reis gdr@integrable-solutions.net
Tue Jun 24 09:43:00 GMT 2008


On Sun, Jun 22, 2008 at 7:42 PM, Kaveh R. GHAZI <ghazi@caip.rutgers.edu> wrote:
> On Sat, 21 Jun 2008, Richard Guenther wrote:
>
>> On Sat, Jun 21, 2008 at 11:11 PM, Ian Lance Taylor <iant@google.com> wrote:
>> > "Richard Guenther" <richard.guenther@gmail.com> writes:
>> >
>> >> On Fri, Jun 20, 2008 at 8:42 PM, Kaveh R. GHAZI <ghazi@caip.rutgers.edu> wrote:
>> >>> This patch fixes the -Wc++-compat warnings in the toplevel [t-z]*.c files.
>> >>> All obvious stuff, i.e. casts etc.  We're down to about 520 warnings or
>> >>> 1/2 way through these.  (Not including Ada or other targets yet.)
>> >>>
>> >>> Bootstrapped on x86_64-unknown-linux-gnu, no regressions.
>> >>
>> >> I don't like this sprinkling casts all over the place.  Since we
>> >> didn't agree to that being the
>> >> right or wrong way to go I alos think these patches are not obvious.
>> >
>> > Most of them are casts away from void*.  We did agree a while back
>> > that gcc would be coded in the C/C++ subset.  That means that you
>> > can't assign from a void* pointer to a pointer of a different type
>> > without a cast.  So either we add casts or we do something else.  But
>> > what?
>>
>> For allocators we have macros in libiberty.  If we end up using C++ I guess
>> we can templatize our datastructures properly.  But as it is not at all clear
>> we will be able to use C++ prematurely adding the casts on the trunk in
>> this "non-nice" way is ... not nice ;)
>> Anyway, I just wanted to raise this issue.
>> Richard.
>
> Hi Richard,
>
> I'm not sure what you mean by "not nice".  You raise three issues: one
> being that the patches themselves aren't obvious enough for me to install,
> the second that we shouldn't use casts and should instead use the
> libiberty macros and/or C++ templates, and the third being that the
> concept of getting the sources into a subset of C and C++ has not achieved
> consensus.
>
> On issue 1, I guess "obviousness" is in the eye of the beholder, I took
> Ian and Gaby's approvals in the thread on gcc@ to give me license to
> proceed.  And to me the changes are obvious, but I can see where someone
> would disagree.

A while back when we discussed this issue for the nth time, it was agreed that
getting the source code compilable with a C++ compiler was `obvious' the change
involved only obvious things like suppressing void* -> T*.  I trust GCC
maintainers (like you) to exercise judgment about ugliness of casts -- casts
are rarely pretty.

-- Gaby



More information about the Gcc-patches mailing list