This is the mail archive of the gcc-patches@gcc.gnu.org mailing 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]

Re: PR28943 Unusable error message when using a conditional-expression with multiple type arguments


"Manuel López-Ibáñez" <lopezibanez@gmail.com> writes:

| On 31 Jan 2007 04:15:12 -0600, Gabriel Dos Reis <gdr@cs.tamu.edu> wrote:
| > "Manuel López-Ibáñez" <lopezibanez@gmail.com> writes:
| >
| > | :ADDPATCH c++:
| > |
| > | The error message for this code:
| > |
| > | void debug (const char * string)
| > | {
| > |   return;
| > | }
| > |
| > | int f()
| > | {
| > |   ( true == false ? 0 : debug ("Some string"));
| > |   return 0;
| > | }
| > |
| > | is:
| > |
| > | error: debug(((const char*)"Some string")) has type void and is not a
| > | throw-expression
| > |
| > | The following patch changes the message to:
| > |
| > | error: 'debug(((const char*)"Some string"))' of type 'void' is
| > | incompatible with '0' of type 'int'
| >
| > "incompatible" tends to have a precise meaning, especially when types
| > are involded.
| >
| > The rule is: if one the operand is of type void, then the other
| > operand must be of type void or a throw expression -- but both cannot
| > be a throw-expression.
| >
| >
| >
| > I would prefer the "improved" diagnostic to say something like
| >
| >    third operand to the conditional operator is of type 'void', but
| >    the second operand is neither a throw-expression nor of type 'void'
| >
| > and swap second/third the other around to cover the symmetric case.
| >
| 
| Don't you think it is helpful to mention the type of the second
| operand or either of the operands? Just asking, I quite like the
| message but I think it could be more informative.

In this particular case, I don't think so; because we have already said
what it is not (i.e. what is expected).  If the type is shown, then the
phrase saying it is not something becomes confusing and at best
redundant. Showing the type does not really help figuring out what is
going on. (In a language where overload resolution is not bottom up,
that may have helped).

-- Gaby


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