Guest User

Untitled

a guest
Jul 18th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. Index: test/SemaCXX/reinterpret-cast.cpp
  2. ===================================================================
  3. --- test/SemaCXX/reinterpret-cast.cpp (revision 89578)
  4. +++ test/SemaCXX/reinterpret-cast.cpp (working copy)
  5. @@ -1,5 +1,7 @@
  6. // RUN: clang-cc -fsyntax-only -verify %s
  7.  
  8. +#include <stdint.h>
  9. +
  10. enum test { testval = 1 };
  11. struct structure { int m; };
  12. typedef void (*fnptr)();
  13. @@ -20,11 +22,11 @@
  14. void integral_conversion()
  15. {
  16. void *vp = reinterpret_cast<void*>(testval);
  17. - long l = reinterpret_cast<long>(vp);
  18. - (void)reinterpret_cast<float*>(l);
  19. - fnptr fnp = reinterpret_cast<fnptr>(l);
  20. + intptr_t i = reinterpret_cast<intptr_t>(vp);
  21. + (void)reinterpret_cast<float*>(i);
  22. + fnptr fnp = reinterpret_cast<fnptr>(i);
  23. (void)reinterpret_cast<char>(fnp); // expected-error {{cast from pointer to smaller type 'char' loses information}}
  24. - (void)reinterpret_cast<long>(fnp);
  25. + (void)reinterpret_cast<intptr_t>(fnp);
  26. }
  27.  
  28. void pointer_conversion()
Add Comment
Please, Sign In to add comment