Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ cat indexudef.c
- #include <stdio.h>
- #define MAX 10
- int main() {
- int a[MAX];
- for (size_t i = 0; i < MAX; ++i) {
- a[i] = i++;
- printf("%3d", a[i]);
- }
- putchar('\n');
- }
- $ gcc-11 -Wall -pedantic -std=c11 -o ../bin/indexudefG indexudef.c
- indexudef.c: In function 'main':
- indexudef.c:10:11: warning: operation on 'i' may be undefined [-Wsequence-point]
- 10 | a[i] = i++;
- | ~^~
- $ ../bin/indexudefG
- 0 2 4 6 8
- $ clang -Wall -pedantic -std=c11 -o ../bin/indexudefC indexudef.c
- indexudef.c:10:11: warning: unsequenced modification and access to 'i' [-Wunsequenced]
- a[i] = i++;
- ~ ^
- 1 warning generated.
- $ ../bin/indexudefC
- 0 2 4 6 8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement