Hi, I did a fair enough search to see if it an already reported bug, or non bug
and I didn't find anything.

Bellow is a simple program that illustrate the problem. The issue only happen
when compiling in 64bits. With -m32 flag it works as expected.
The issue seems to be when va_list in returned in a function, it is recognized
as an array, so then the compiler shows:

test1.c:5: error: ‘foo’ declared as function returning an array 

---------------------------------------
/* test1.c*/
#include <stdio.h>
#include <stdarg.h>

static va_list foo(va_list vap)
{
    int mp;
    mp = va_arg(vap, int);
    printf("foo: %d\n",mp);
    return (vap);
}

void f1(int i, ...)
{
  va_list vl;

  va_start(vl, i);
  vl = foo(vl);
  vl = foo(vl);
  vl = foo(vl);
  va_end(vl);

}

int main(int argc, char **argv)
{
  f1(1,2,3,4);
  return 0;
}

-------------------------------------------------------------------------

compiled in 32bits it compile fine with no warnings and works

>>gcc -m32 -Wall test1.c -o test1.o
>>./test1.o
foo: 2
foo: 3
foo: 4

--------------------------------------------------------------------------

When trying to compile for 64bits the compiler rises the following errors:

>>gcc -m64 test1.c -o test1.o
test1.c:5: error: ‘foo’ declared as function returning an array
test1.c: In function ‘foo’:
test1.c:9: warning: return makes integer from pointer without a cast
test1.c: In function ‘f1’:
test1.c:17: error: incompatible types in assignment
test1.c:18: error: incompatible types in assignment
test1.c:19: error: incompatible types in assignment

---------------------------------

>gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk
--disable-dssi --enable-plugin
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic
--host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20070626 (Red Hat 4.1.2-14)


-- 
           Summary: va_list is treatead as an array when complied in 64bits
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fede dot naum at gmail dot com
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36914

Reply via email to