Advertisement
karlicoss

ням

Sep 2nd, 2014
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. // 1
  2. struct crap
  3. {
  4.     int kek;
  5.     void shit() {
  6.         return kek;
  7.     }
  8. };
  9.  
  10. int main() {
  11.     crap test;
  12.     return 0;
  13. }
  14. $ clang++ main.cpp -> error: void function 'shit' should not return a value [-Wreturn-type]
  15.  
  16. // 2
  17. template<typename T>
  18. struct crap
  19. {
  20.     int kek;
  21.     void shit() {
  22.         return kek;
  23.     }
  24. };
  25.  
  26. int main() {
  27.     crap<int> test;
  28.     return 0;
  29. }
  30. $ clang++ main.cpp -> OK
  31.  
  32. // 3
  33. template<typename T>
  34. struct crap
  35. {
  36.     int kek;
  37.     void shit() {
  38.         return kek;
  39.     }
  40. };
  41.  
  42. int main() {
  43.     crap<int> test;
  44.     test.shit();
  45.     return 0;
  46. }
  47. $ clang++ test.cpp
  48. test.cpp:6:3: error: void function 'shit' should not return a value [-Wreturn-type]
  49.                 return kek;
  50.                 ^      ~~~
  51. test.cpp:12:7: note: in instantiation of member function 'crap<int>::shit' requested here
  52.         test.shit();
  53.              ^
  54. 1 error generated.
  55.  
  56. //4
  57. template<typename T>
  58. struct crap
  59. {
  60.     void shit() {
  61.         return 0;
  62.     }
  63. };
  64.  
  65. int main() {
  66.     return 0;
  67. }
  68. $ clang++ test.cpp
  69. test.cpp:5:9: error: void function 'shit' should not return a value [-Wreturn-type]
  70.         return 0;
  71.         ^      ~
  72. 1 error generated.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement