Advertisement
alansam

Sequence error show & tell.

Apr 1st, 2020
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.34 KB | None | 0 0
  1. $ cat a.c
  2.  
  3. #include <stdio.h>
  4.  
  5. int main()
  6. {
  7.   int q = 1;
  8.   q = q++ + ++q * --q - q--;
  9.   printf("a = %d\n", q);
  10.  
  11.   return 0;
  12. }
  13.  
  14. $ gcc-9 a.c
  15. $ ./a.out
  16. a = 3
  17. $ clang a.c
  18. a.c:7:8: warning: multiple unsequenced modifications to 'q' [-Wunsequenced]
  19.   q = q++ + ++q * --q - q--;
  20.        ^    ~~
  21. 1 warning generated.
  22. $ ./a.out
  23. a = 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement