Can I make GCC warn on passing too-wide types to functions?

Use -Wconversion — the problem is an implicit cast (conversion) from long x to short when the function f(short x) is called [not printf], and -Wconversion will say something like “cast from long to short may alter value”.

..

Edit: just saw your note. -Wconversion results in a warning for me, using g++ 4.3.2 on Linux… (4.3.2-1 on Debian)

Leave a Comment