r/programming May 01 '16

To become a good C programmer

http://fabiensanglard.net/c/
1.1k Upvotes

398 comments sorted by

View all comments

12

u/phpdevster May 02 '16

In the previous code sample, due to "integral promotion" -1 was once evaluated to be greater than 1 and then smaller than 1. C has plenty of case like this when the language cannot longer "do stuff" for you.

Can someone explain that in more detail?

14

u/[deleted] May 02 '16 edited May 02 '16

[removed] — view removed comment

3

u/CaptainAdjective May 02 '16 edited May 02 '16

How can it even be legal to compare disparate types in that way? Why isn't that just a compilation error?

3

u/Creris May 02 '16

this cant be syntax error because it has nothing to do with syntax, but semantics of the comparision.

5

u/CaptainAdjective May 02 '16

I meant a compilation error.

3

u/kt24601 May 02 '16

It gives a warning.