Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include <cstdint>
  2.  
  3. struct Struct
  4. {
  5. int16_t val;
  6. };
  7.  
  8. int main()
  9. {
  10. int16_t a = 0;
  11. //Struct b = {.val = a}; // No warning
  12. Struct b = {.val = a-1}; // Warning
  13. (void)b;
  14. return 0;
  15. }
  16.  
  17. test.cpp: In function ‘int main()’:
  18. test.cpp:12:29: warning: narrowing conversion of ‘(((int)a) + -1)’ from ‘int’ to ‘int16_t {aka short int}’ inside { } [-Wnarrowing]
  19. Struct b = {.val = a-1};
  20. ^
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement