Bug 1314545

Summary: error: first argument to ‘va_arg’ not of type ‘va_list’ in C++ on s390(x)
Product: [Fedora] Fedora Reporter: Dan Horák <dan>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 24CC: davejohansen, jakub, jwakely, law, mpolacek
Target Milestone: ---   
Target Release: ---   
Hardware: s390x   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-03-10 14:44:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 467765    
Attachments:
Description Flags
preprocessed source file none

Description Dan Horák 2016-03-03 21:18:57 UTC
Build of glibmm24-2.47.4-2.fc24 fails on s390(x) with gcc-c++-6.0.0-0.14.fc24 with an error, while it succeeds elsewhere.

from build.log at http://s390.koji.fedoraproject.org/koji/taskinfo?taskID=2135162

...
libtool: compile:  g++ -DHAVE_CONFIG_H -I.. -I../.. -DG_LOG_DOMAIN=\"glibmm\" -DGLIBMM_BUILD=1 -pthread -I/usr/include/sigc++-2.0 -I/usr/lib64/sigc++-2.0/include -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -Wall -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -march=z9-109 -mtune=z10 -c object.cc  -fPIC -DPIC -o .libs/object.o
In file included from /usr/include/glib-2.0/glib/gerror.h:27:0,
                 from /usr/include/glib-2.0/glib/gthread.h:33,
                 from /usr/include/glib-2.0/glib/gasyncqueue.h:32,
                 from /usr/include/glib-2.0/glib.h:32,
                 from /usr/include/glib-2.0/gobject/gbinding.h:28,
                 from /usr/include/glib-2.0/glib-object.h:23,
                 from ../glibmm/class.h:25,
                 from ../glibmm/objectbase.h:22,
                 from ../glibmm/object.h:28,
                 from object.cc:18:
object.cc: In constructor 'Glib::ConstructParams::ConstructParams(const Glib::Class&, const char*, ...)':
/usr/include/glib-2.0/gobject/gvaluecollector.h:105:41: error: first argument to 'va_arg' not of type 'va_list'
    _cvalue->v_int = va_arg ((var_args), gint);     \
                     ~                    
/usr/include/glib-2.0/gobject/gvaluecollector.h:156:3: note: in expansion of macro 'G_VALUE_COLLECT_INIT'
   G_VALUE_COLLECT_INIT(value, _value_type, var_args, flags, __error);   \
   ^~~~~~~~~~~~~~~~~~~~
object.cc:109:5: note: in expansion of macro 'G_VALUE_COLLECT'
     G_VALUE_COLLECT(&param.value, var_args, 0, &collect_error);
     ^~~~~~~~~~~~~~~
/usr/include/glib-2.0/gobject/gvaluecollector.h:108:42: error: first argument to 'va_arg' not of type 'va_list'
    _cvalue->v_long = va_arg ((var_args), glong);     \
                      ~                    
/usr/include/glib-2.0/gobject/gvaluecollector.h:156:3: note: in expansion of macro 'G_VALUE_COLLECT_INIT'
   G_VALUE_COLLECT_INIT(value, _value_type, var_args, flags, __error);   \
   ^~~~~~~~~~~~~~~~~~~~
object.cc:109:5: note: in expansion of macro 'G_VALUE_COLLECT'
     G_VALUE_COLLECT(&param.value, var_args, 0, &collect_error);
     ^~~~~~~~~~~~~~~
/usr/include/glib-2.0/gobject/gvaluecollector.h:111:43: error: first argument to 'va_arg' not of type 'va_list'
    _cvalue->v_int64 = va_arg ((var_args), gint64);    \
                       ~                    
/usr/include/glib-2.0/gobject/gvaluecollector.h:156:3: note: in expansion of macro 'G_VALUE_COLLECT_INIT'
   G_VALUE_COLLECT_INIT(value, _value_type, var_args, flags, __error);   \
   ^~~~~~~~~~~~~~~~~~~~
object.cc:109:5: note: in expansion of macro 'G_VALUE_COLLECT'
     G_VALUE_COLLECT(&param.value, var_args, 0, &collect_error);
     ^~~~~~~~~~~~~~~
/usr/include/glib-2.0/gobject/gvaluecollector.h:114:44: error: first argument to 'va_arg' not of type 'va_list'
    _cvalue->v_double = va_arg ((var_args), gdouble);    \
                        ~                    
/usr/include/glib-2.0/gobject/gvaluecollector.h:156:3: note: in expansion of macro 'G_VALUE_COLLECT_INIT'
   G_VALUE_COLLECT_INIT(value, _value_type, var_args, flags, __error);   \
   ^~~~~~~~~~~~~~~~~~~~
object.cc:109:5: note: in expansion of macro 'G_VALUE_COLLECT'
     G_VALUE_COLLECT(&param.value, var_args, 0, &collect_error);
     ^~~~~~~~~~~~~~~
/usr/include/glib-2.0/gobject/gvaluecollector.h:117:45: error: first argument to 'va_arg' not of type 'va_list'
    _cvalue->v_pointer = va_arg ((var_args), gpointer);    \
                         ~                    
/usr/include/glib-2.0/gobject/gvaluecollector.h:156:3: note: in expansion of macro 'G_VALUE_COLLECT_INIT'
   G_VALUE_COLLECT_INIT(value, _value_type, var_args, flags, __error);   \
   ^~~~~~~~~~~~~~~~~~~~
object.cc:109:5: note: in expansion of macro 'G_VALUE_COLLECT'
     G_VALUE_COLLECT(&param.value, var_args, 0, &collect_error);
     ^~~~~~~~~~~~~~~
Makefile:744: recipe for target 'object.lo' failed


The source source is https://git.gnome.org/browse/glibmm/tree/glib/glibmm/object.cc?id=42a47cb78e4815da6d6ebccafda864326fcdd22c#n69
and then https://git.gnome.org/browse/glib/tree/gobject/gvaluecollector.h?h=2.47.5#n88

I have reduced the code and I'm getting an error on s390x, but not on x86_64

[sharkcz@devel10 glibmm]$ cat a.cc
#include <cstdarg>

class A
{
public:
    A(const char* f, ...);
};

A::A(const char *f, ...)
{
  va_list var_args;
  va_start(var_args, f);

  int i;
  i = va_arg ((var_args), int);

  va_end(var_args);
}
[sharkcz@devel10 glibmm]$ g++ -Wall -O2 -Wall -c a.cc -o a.o
a.cc: In constructor ‘A::A(const char*, ...)’:
a.cc:14:7: warning: variable ‘i’ set but not used [-Wunused-but-set-variable]
   int i;
       ^
In file included from /usr/include/c++/6.0.0/cstdarg:43:0,
                 from a.cc:1:
a.cc: In constructor ‘A::A(const char*, ...)’:
a.cc:15:27: error: first argument to ‘va_arg’ not of type ‘va_list’
   i = va_arg ((var_args), int);
       ~                    
[sharkcz@devel10 glibmm]$ rpm -q gcc-c++
gcc-c++-6.0.0-0.14.fc24.s390x


while compile on x86_64 returns:

<mock-chroot>sh-4.3# g++ -Wall -O2 -Wall -c a.cc -o a.o
a.cc: In constructor 'A::A(const char*, ...)':
a.cc:14:7: warning: variable 'i' set but not used [-Wunused-but-set-variable]
   int i;
       ^
<mock-chroot>sh-4.3# rpm -q gcc-c++
gcc-c++-6.0.0-0.13.fc24.x86_64

Comment 1 Dan Horák 2016-03-03 21:23:53 UTC
It might be still an incorrect code, but why the result is inconsistent between arches? Doesn't have "stdarg" a specific implementation on s390(x)?

Comment 2 Dan Horák 2016-03-04 13:52:08 UTC
cannot be reproduced with gcc 5.3 and -std=c++14

[sharkcz@devel6 ~]$ g++ -std=c++14 -O2 -Wall -c a.cc -o a.o
a.cc: In constructor ‘A::A(const char*, ...)’:
a.cc:14:7: warning: variable ‘i’ set but not used [-Wunused-but-set-variable]
   int i;
       ^
[sharkcz@devel6 ~]$ rpm -q gcc-c++
gcc-c++-5.3.1-2.fc23.s390x

Comment 3 Dan Horák 2016-03-04 13:56:58 UTC
Created attachment 1133167 [details]
preprocessed source file

with gcc-c++-6.0.0-0.14.fc24.s390x

Comment 4 Dan Horák 2016-03-04 14:02:00 UTC
and yes, removing the extra parentheses around the first argument in va_arg() makes the error go away

Comment 5 Jonathan Wakely 2016-03-04 14:03:29 UTC
There have been some G++ bugs relating to extra parens causing problems in C++14 mode, this looks like another of those.

Comment 6 Dan Horák 2016-03-05 19:02:32 UTC
The problem went away when gcc-6.0.0-0.15.fc24 was used in the build.

Comment 7 Marek Polacek 2016-03-10 14:44:07 UTC
The fix is in gcc-6.0.0-0.15.fc24, closing.