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


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. Although showing the operands may take a lot of space for some expressions.

Let me know your opinion and I will implement that.

Cheers,

Manuel.


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