I am trying to compile fairly simple C ++ code with GCC 6, but I get a narrower conversion warning. This is problematic because we view warnings as errors.
struct S {
short int a;
short int b;
};
short int getFoo();
short int getBar();
std::array<S, 2> arr = {{
{5, getFoo()},
{3, getFoo() + getBar()}
}};
This code can be seen at https://godbolt.org/g/wHNxoc . GCC says getFoo () + getBar () narrows from int down to short int. What causes a raise to int? Is there any good solution here besides force casting to short int?
source
share