Advertisement
Guest User

Untitled

a guest
Jul 29th, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.18 KB | None | 0 0
  1. mitalia@mitalia:~/scratch$ cat testptr.c
  2. void test()
  3. {
  4.     int a; int *b=a;
  5. }
  6. mitalia@mitalia:~/scratch$ clang -ansi -pedantic -c testptr.c
  7. testptr.c:3:17: warning: incompatible integer to pointer conversion initializing 'int *' with an expression of type 'int'; take the address with & [-Wint-conversion]
  8.     int a; int *b=a;
  9.                 ^ ~
  10.                   &
  11. 1 warning generated.
  12. mitalia@mitalia:~/scratch$ gcc -ansi -pedantic -c testptr.c
  13. testptr.c: In functiontest’:
  14. testptr.c:3:19: warning: initialization makes pointer from integer without a cast [enabled by default]
  15.      int a; int *b=a;
  16.                    ^
  17. mitalia@mitalia:~/scratch$ cat testptr.cpp
  18. void test()
  19. {
  20.     int a; int *b=a;
  21. }
  22. mitalia@mitalia:~/scratch$ clang++ -ansi -pedantic -c testptr.cpp
  23. testptr.cpp:3:17: error: cannot initialize a variable of type 'int *' with an lvalue of type 'int'
  24.     int a; int *b=a;
  25.                 ^ ~
  26. 1 error generated.
  27. mitalia@mitalia:~/scratch$ g++ -ansi -pedantic -c testptr.cpp
  28. testptr.cpp: In function ‘void test()’:
  29. testptr.cpp:3:19: error: invalid conversion from ‘int’ to ‘int*[-fpermissive]
  30.      int a; int *b=a;
  31.                    ^
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement