[PING^3] Wconversion: fixes for C++ front-end

Manuel López-Ibáñez lopezibanez@gmail.com
Thu Feb 8 11:55:00 GMT 2007


On 07/02/07, Gabriel Dos Reis <gdr@cs.tamu.edu> wrote:
> On Wed, 7 Feb 2007, Manuel López-Ibáñez wrote:
>
>
>   (1) standard conversion sequence, followed by
>   (2) a possible user-defined conversion, followed by
>   (3) another standard conversion sequence.
>
> In both (1) and (3) you want to catch non-value preserving
> conversions.  And ocp_convert's job is to implement each step of the
> conversion sequences.
>
> Both convert() and cp_convert() essentially asks for doing the same
> kind of conversions.  They differ in "who" is allowed to participating
> in the conversion sequence.  More precisely, convert() cares only
> about _standard conversion_ sequences.  cp_convert() tolerates
> user-defined conversions.  It looks to me that you wan to have
> ocp_convert() actually warns if necessary, instead of doing the
> computations twice and throwing one results away.

Thanks for the explanation. My knowledge about the C++ front-end is
very limited and the conversion code is specially confusing to me.
Thus, any help is greatly appreciated.

I am not so sure that I want to have ocp_convert to warn if necessary.
In the same way as the C front-end has both convert_and_check and
convert, and the former is used in just a few places, I don't think
that invoking the warnings for every call to ocp_convert can actually
work.

Another problem is that I would need to encapsulate the warning logic
in convert_and_check on its own function, so it can be called from
convert_and_check and ocp_convert. That is fine except for the fact
that the C++ front-end already uses convert_and_check in a few places,
which in turn calls convert, which in turn calls ocp_convert, that
would generate warnings again. How could we fix this situation?

Third, the way that convert_and_check works is to invoke the original
convert and afterwards check the result and warn about
overflow/conversions. That cannot be implemented within ocp_convert
without modifying the whole ocp_convert, since there is not a single
conversion result but a lot of 'return' statements. It can be done
(for example, invoking the conversion warnings before each return) but
do you really want me to do this?


I would like to implement this in the best possible way but I don't
see how can I solve the problems described above. Do you have any
suggestions? Again, thanks for your help on solving this.

Cheers,

Manuel.



More information about the Gcc-patches mailing list