Gabriel Dos Reis - Re: [PING^3] Wconversion: fixes for C++ front-end (original) (raw)

This is the mail archive of the gcc-patches@gcc.gnu.orgmailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

On Wed, 7 Feb 2007, Manuel López-Ibáñez wrote:

| On 06 Feb 2007 18:46:44 -0600, Gabriel Dos Reis gdr@cs.tamu.edu wrote: | > "Manuel López-Ibáñez" lopezibanez@gmail.com writes: | > | > [...] | > | > | So the basic differences are the call to fold_if_not_in_template and | > | the use of LOOKUP_NO_CONVERSION when calling ocp_convert. I honestly | > | cannot see how to relate cp_convert and convert. | > | > In that case, there does not seem reason to believe that the chain you | > introduced is correct. We must conservatitely regard it as incorrect | > until proven otherwise. the conversion code in cp/ has proven to be | > tricky and sources of bugs, hence the caution that must be exercise. | | That is the reason for not using the return value of | convert_and_check.

actually it is a reason to be careful about calling the conversion functions. I suspect I did not make my previous points clear enough:

(1) you must understand why you call each of the functions (2) given that both convert() and cp_convert() convert, you must understand their relations. Just quoting the definitions at me is NOT what I was trying to get at. (4) if you must call one function that does conversion, potentially issues diagnostic but throws its result away, just to call another conversion function that does similar computations, then something is wrong. (5) you must be able to explain your patch, what it does and why it does it.

The difference here is in the flag parameters. Before a new function cp_convert_and_check is introduced, you must explain why the existing ones are insufficient -- that brings you back to understanding ocp_convert.

Conversions in C++ can involve not just standard conversions (implicit conversions defined for built-in types), but also user-defined conversions. There is a well-defined ordering in which they must happen -- see clause 4 of the C++ standard.

An implicit conversion sequence in C++ (they actions you need to take to bring arguments to parameter types, etc.) in general is:

(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.

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]