https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123153
--- Comment #1 from David Binderman <dcb314 at hotmail dot com> ---
Here is some C++ code that demonstrates the problem:
extern void f( int);
void g()
{
f( 0.5);
}
gcc says nothing:
Alphasrc $ ~/gcc/results/bin/gcc -c -g -O2 -Wall -Wextra -pedantic dec16c.cc
Alphasrc $
Here is clang finding the problem:
Alphasrc $ clang++ -c dec16c.cc
dec16c.cc:6:5: warning: implicit conversion from 'double' to 'int' changes
value from 0.5 to 0 [-Wliteral-conversion]
6 | f( 0.5);
| ~ ^~~
1 warning generated.
Only with some little known encouragement can gcc be persuaded
to find the problem:
Alphasrc $ ~/gcc/results/bin/gcc -c -g -O2 -Wall -Wextra -pedantic -Wconversion
dec16c.cc
dec16c.cc: In function ‘void g()’:
dec16c.cc:6:12: warning: conversion from ‘double’ to ‘int’ changes value from
‘5.0e-1’ to ‘0’ [-Wfloat-conversion]
6 | f( 0.5);
| ^~~
Alphasrc $