[cfe-dev] Wrong diagnostic for ternary operator
Steve Naroff
snaroff at apple.com
Thu Jul 26 07:43:03 PDT 2007
Thanks for the bug report. Just checked in a fix...
snaroff
On Jul 25, 2007, at 10:27 PM, Jeroen Ruigrok van der Werven wrote:
> This is a simplification of some code I let clang loose on:
>
> #include <stdio.h>
>
> int
> main(void) {
> int test = 0;
>
> printf("Type is %s\n", (test >= 1 ? "short" : "char"));
>
> return (0);
> }
>
> It comes up with a diagnostic that's misleading upon first read.
>
> t.c:7:36: error: incompatible operand types ('char *' and 'char *')
> printf("Type is %s\n", (test >= 1 ? "short" : "char"));
> ^ ~~~~~~~ ~~~~~~
> 1 diagnostic generated.
>
> I think the average developer will wonder why "short" and "char" are
> incompatible, especially since the tildes draw attention to that.
> The accent
> circumflex gets lost in the noise.
>
> The code in question used this to toggle which text to use in a %s
> argument to
> a printf() call and is quite valid.
>
> --
> Jeroen Ruigrok van der Werven <asmodai(-at-)in-nomine.org> / asmodai
> イェルーン ラウフロック ヴァン デル ウェルヴェン
> http://www.in-nomine.org/ | http://www.rangaku.org/
> The last word in a chronicle is never set down...
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list