GLib format strings for int64 values don't require "ll" modifier - causes segfault on 32-bit arches
@mjog
Submitted by Michael Gratton Link to original bug (#767839)
Description
When formatting an int64 value using GLib format strings (e.g. say using GLib.debug), valac is not complaining if the correct length modifier is not set, i.e. "ll".
While valac does not complain about this, gcc does on the translated C file, but that's basically impossible to spot amounts all of the warnings gcc spits out unsless you go looking for it.
For example, valac will compile this fine, without warning:
void main () {
int64 x = 0;
debug(" " + "%d", x);
}
Valac should instead require "%lld" as the format string, as gcc points out.
test.vala.c:13:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘gint64’ {aka ‘long int’} [-Wformat=]
13 | g_debug (" " "%d", x);
| ^~~ ~
| |
| gint64 {aka long int}
This will cause programs to segfault on 32-bit arches.
Version: 0.32.x
Edited by Rico Tzschichholz