Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdint>
- struct Struct
- {
- int16_t val;
- };
- int main()
- {
- int16_t a = 0;
- //Struct b = {.val = a}; // No warning
- Struct b = {.val = a-1}; // Warning
- (void)b;
- return 0;
- }
- test.cpp: In function ‘int main()’:
- test.cpp:12:29: warning: narrowing conversion of ‘(((int)a) + -1)’ from ‘int’ to ‘int16_t {aka short int}’ inside { } [-Wnarrowing]
- Struct b = {.val = a-1};
- ^
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement