GNOME Bugzilla – Bug 720708
g_assert_warning(): number of arguments doesn't match format string
Last modified: 2014-06-28 17:40:11 UTC
The bulk of g_assert_warning() is: g_log (log_domain, G_LOG_LEVEL_ERROR, expression ? "file %s: line %d (%s): assertion failed: (%s)" : "file %s: line %d (%s): should not be reached", file, line, pretty_function, expression); If expression == NULL, then the above reduces to: g_log (log_domain, G_LOG_LEVEL_ERROR, "filer %s: line %d (%s): should not be reached", file, line, pretty_function, expression); The format string expects 3 arguments, but 4 are given. According to http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf page 309 (327th of document): "If the format is exhausted while arguments remain, the excess arguments are evaluated (as always) but are otherwise ignored." so the current code strictly speaking is legal. The downside is that you keep seeing a false positive if you build with -Wformat-extra-args, which is a useful flag, as usually it just finds places where an argument was added, and the format string not updated. Maybe we could change the code to the less cunning, but more compiler friendly: if (expression) g_log (log_domain, G_LOG_LEVEL_ERROR, "file %s: line %d (%s): assertion failed: (%s)" file, line, pretty_function, expression); else g_log (log_domain, G_LOG_LEVEL_ERROR, "file %s: line %d (%s): should not be reached", file, line, pretty_function); ?
Created attachment 265319 [details] [review] avoid -Wformat-extra-args build errors
ping?
This is an internally-used macro only. I'd prefer if we could split it up into two separate macros instead.
Review of attachment 265319 [details] [review]: Sorry -- my mistake. I thought this was a macro, not a deprecated function. Please commit.