I decided to test compile a project with -Wsign-conversion enabled, to see what warnings would come up, and came across something that doesn't seem right, where gcc behaves differently than clang. Can someone please tell me which is correct?
I have a function that takes a size_t param:
void func(size_t) {}
Run Code Online (Sandbox Code Playgroud)
some other struct
struct Test {};
Run Code Online (Sandbox Code Playgroud)
and calling code
int i = some_initialiser();
func(sizeof(Test) + static_cast<size_t>(i));
Run Code Online (Sandbox Code Playgroud)
So from my understanding, sizeof returns size_t, and arithmetic between two variables …