alansam

hw106

Jan 20th, 2022 (edited)
281
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $ cat hw106.c
  2.  
  3. #include <stdio.h>
  4.  
  5. int main() {
  6.   int x = 2;
  7.   printf("%d %d %d\n", x * x, ++x, x++);
  8. }
  9.  
  10. $ clang -Wall -pedantic -std=c11 -o ../../bin/hw106C hw106.c
  11. hw106.c:6:31: warning: unsequenced modification and access to 'x' [-Wunsequenced]
  12.   printf("%d %d %d\n", x * x, ++x, x++);
  13.                        ~      ^
  14. 1 warning generated.
  15. $ gcc-11 -Wall -pedantic -std=c11 -o ../../bin/hw106G hw106.c
  16. hw106.c: In function 'main':
  17. hw106.c:6:37: warning: operation on 'x' may be undefined [-Wsequence-point]
  18.     6 |   printf("%d %d %d\n", x * x, ++x, x++);
  19.       |                                    ~^~
  20. hw106.c:6:37: warning: operation on 'x' may be undefined [-Wsequence-point]
  21. hw106.c:6:37: warning: operation on 'x' may be undefined [-Wsequence-point]
  22.  
  23. $ ../../bin/hw106C
  24. 4 3 3
  25. $ ../../bin/hw106G
  26. 16 4 2
  27.  
RAW Paste Data Copied