[C++][Cortex-M7] Ambiguous call of overloaded function fn(int): fn(int32_t) vs fn(int64_t)
Compilation of C++ code:
#include <cstdint>
int fn(int32_t x)
{
return (int)x;
}
int fn(int64_t x)
{
return (int)x;
}
extern "C" void _exit(int code)
{
while (1) {}
}
int main(void)
{
return fn(3);
}
reports an error:
gcc-arm-
main.cpp: In function 'int main()':
main.cpp:20:14: error: call of overloaded 'fn(int)' is ambiguous
return fn(3);
^
main.cpp:3:5: note: candidate: int fn(int32_t)
int fn(int32_t x)
^~
main.cpp:8:5: note: candidate: int fn(int64_t)
int fn(int64_t x)
^~
Isn't the int32_t variant the obvious one to select on Cortex-M7 (its core registers are 32-bit)? At least IAR compiler selects that one. I'm writing a portable code and I would like to have the correct function selected automatically.
Question information
- Language:
- English Edit question
- Status:
- Expired
- Assignee:
- No assignee Edit question
- Last query:
- Last reply: