GNOME Bugzilla – Bug 168387
gnome-program.c compile error
Last modified: 2005-03-05 21:58:33 UTC
gnome-program.c: In function `gnome_program_init_paramv': gnome-program.c:1931: error: invalid initializer Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc --disable-multilib powerpc-linux Thread model: posix gcc version 3.3.5 (Debian 1:3.3.5-8)
the C99 rationale says : « The va_list type is not necessarily assignable. However, a function can pass a pointer to its initialized argument list object, as noted below. »
see http://gcc.gnu.org/ml/gcc-patches/2002-04/msg01195.html
Created attachment 37899 [details] [review] Handle both array and non-array va_list types.
Comment on attachment 37899 [details] [review] Handle both array and non-array va_list types. bad patch
Is there a good patch missing here? :-)
i took me some time to understand exactly the workaround provided on gcc's bugzilla. But i still don't know how portably initialize an empty va_list. May be it gnome_program_init_common should take a va_list* so we can pass it NULL ?
There's a different bug report for this where someone reported that it compiled fine when inited to = {}. Does that work for you too?
yes, but {} is not a valid initializer for scalar. If va_list is not an array type, it's an error. I think that the main question is : is a zero-initialized va_list a valid empty va_list ?
no, libgnomeui 2.8.1 doesn't build on alpha because of that: http://buildd.debian.org/fetch.php?&pkg=libgnome&ver=2.8.1-1&arch=alpha&stamp=1109255817&file=log&as=raw
Created attachment 37913 [details] testcase
Created attachment 37914 [details] [review] proposed patch
Created attachment 37916 [details] [review] updated replaced C99 va_copy by G_VA_COPY
*** Bug 168110 has been marked as a duplicate of this bug. ***
*** Bug 168859 has been marked as a duplicate of this bug. ***
Created attachment 38099 [details] [review] gnome-program-64bit.patch As I said in the other bug report, the only real problem here is that a code analysis tools spit out a warning. This is a minimal patch fixes the compile error, and adds a check to make absolutely sure that "args" won't actually be used by gnome_program_init_common(). The code analysis tools will probably still complain though. At this stage in the release process, a minimal patch is probably better than a more extensive one like attachment 37916 [details] [review].
Commited the simple fix.
It's still broken if someone changes the behaviour of gnome_program_init_common(). Please add a comment/FIXME :)
*** Bug 169332 has been marked as a duplicate of this bug. ***