Advertisement
Guest User

non-const ptr to const char* literal

a guest
Sep 30th, 2013
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. [~/src] cat test.cpp
  2. int main()
  3. {
  4. char* a = "hello";
  5. return 0;
  6. }
  7. [~/src] g++ --version
  8. g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3)
  9. Copyright (C) 2010 Free Software Foundation, Inc.
  10. This is free software; see the source for copying conditions. There is NO
  11. warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12.  
  13. [~/src] g++ -o test.exe test.cpp
  14. test.cpp: In function ‘int main()’:
  15. test.cpp:3: warning: deprecated conversion from string constant to ‘char*’
  16. [~/src] g++ -Wall -o test.exe test.cpp
  17. test.cpp: In function ‘int main()’:
  18. test.cpp:3: warning: deprecated conversion from string constant to ‘char*’
  19. test.cpp:3: warning: unused variable ‘a’
  20. [~/src] vanilla-g++-4.7.2 -o test.exe test.cpp
  21. test.cpp: In function ‘int main()’:
  22. test.cpp:3:12: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
  23. [~/src] vanilla-g++-4.7.2 -Wall -o test.exe test.cpp
  24. test.cpp: In function ‘int main()’:
  25. test.cpp:3:12: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
  26. test.cpp:3:8: warning: unused variable ‘a’ [-Wunused-variable]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement