Warn about do nothing expressions?

Frustrated Who at where.com
Sat Mar 29 09:21:54 PDT 2014


On Friday, 28 March 2014 at 20:59:34 UTC, Justin Whear wrote:
> On Fri, 28 Mar 2014 19:35:20 +0000, Frustrated wrote:
>
>> 
>> either way, all increment i, which actually never happens in 
>> D. As was
>> pointed out, VS does it properly... D does it wrong. Accept it 
>> and stop
>> trying to validate how D does it so you can say D is correct.
>> 
>> Not only is it logically wrong, it is not consistent with 
>> previous
>> interpretations of other compilers/languages nor with itself. 
>> It is
>> wrong on all levels. Just because you believe in unicorns 
>> doesn't prove
>> that they exist. All the evidence says you are wrong.
>> 
>
> Nope, Frustrated is the one who is dead wrong.
>
> test.c:
> -----------------------------
> #include <stdio.h>
>
> int main()
> {
> 	int i = 0;
> 	i = i++;
> 	printf("%i\n", i);
> 	return 0;
> }
> -----------------------------
>
> $ gcc test.c && ./a.out
> 0
>
> $ clang test.c && ./a.out
> test.c:7:7: warning: multiple unsequenced modifications to 'i' 
> [-
> Wunsequenced]
>         i = i++;
>           ~  ^
> 1 warning generated.
> 0
>
>
> Both gcc and clang agree that in C, assigning a post-increment 
> to itself
> results in the original value.  At least Clang warns, which is 
> good, but
> D is consistent with C's behavior on this point.
>
> Justin


Oh yeah, this makes hell of a lot of sense. I'm the one who's 
wrong, yet monarch claims it his is correct and yet clang gives a 
warning. Great logic there! I'll be sure to mark every post you 
have as special so I can study your logic to become so smart.


More information about the Digitalmars-d mailing list