Author: diego Date: Thu Nov 3 15:23:17 2011 New Revision: 34290 Log: configure: add braces to initializer in vsscanf test to shut up a gcc warning Modified: trunk/configure Modified: trunk/configure ============================================================================== --- trunk/configure Thu Nov 3 15:23:14 2011 (r34289) +++ trunk/configure Thu Nov 3 15:23:17 2011 (r34290) @@ -3843,7 +3843,7 @@ cat > $TMPC << EOF #define _ISOC99_SOURCE #include <stdarg.h> #include <stdio.h> -int main(void) { va_list ap = { 0 }; vsscanf("foo", "bar", ap); return 0; } +int main(void) { va_list ap = { { 0 } }; vsscanf("foo", "bar", ap); return 0; } EOF cc_check || { vsscanf=no ; def_vsscanf='#undef HAVE_VSSCANF' ; } echores "$vsscanf"
On Thu, Nov 03, 2011 at 03:23:17PM +0100, diego wrote:
Author: diego Date: Thu Nov 3 15:23:17 2011 New Revision: 34290
Log: configure: add braces to initializer in vsscanf test to shut up a gcc warning
Modified: trunk/configure
Modified: trunk/configure ============================================================================== --- trunk/configure Thu Nov 3 15:23:14 2011 (r34289) +++ trunk/configure Thu Nov 3 15:23:17 2011 (r34290) @@ -3843,7 +3843,7 @@ cat > $TMPC << EOF #define _ISOC99_SOURCE #include <stdarg.h> #include <stdio.h> -int main(void) { va_list ap = { 0 }; vsscanf("foo", "bar", ap); return 0; } +int main(void) { va_list ap = { { 0 } }; vsscanf("foo", "bar", ap); return 0; }
I think you've made that kind of mistake before. The standard does not make any promises about the layout of va_list. Thus your new code can and probably will fail to compile on systems with perfectly fine vsscanf support. The original code was correct, just not initializing at all would be correct, using memset would be correct, going crazy and adding a var-arg function and properly using va_start would be too. But this one is not. No idea which of these do or do not cause warnings.
On Thu, Nov 03, 2011 at 08:05:49PM +0100, Reimar Döffinger wrote:
On Thu, Nov 03, 2011 at 03:23:17PM +0100, diego wrote:
Log: configure: add braces to initializer in vsscanf test to shut up a gcc warning
--- trunk/configure Thu Nov 3 15:23:14 2011 (r34289) +++ trunk/configure Thu Nov 3 15:23:17 2011 (r34290) @@ -3843,7 +3843,7 @@ cat > $TMPC << EOF #define _ISOC99_SOURCE #include <stdarg.h> #include <stdio.h> -int main(void) { va_list ap = { 0 }; vsscanf("foo", "bar", ap); return 0; } +int main(void) { va_list ap = { { 0 } }; vsscanf("foo", "bar", ap); return 0; }
I think you've made that kind of mistake before. The standard does not make any promises about the layout of va_list. Thus your new code can and probably will fail to compile on systems with perfectly fine vsscanf support. The original code was correct, just not initializing at all would be correct, using memset would be correct, going crazy and adding a var-arg function and properly using va_start would be too. But this one is not. No idea which of these do or do not cause warnings.
Thanks for the heads-up, fixed locally, will push in a few. Diego
participants (3)
-
diego -
Diego Biurrun -
Reimar Döffinger