[Bug c/36914] New: va_list is treatead as an array when complied in 64bits

2008-07-23 Thread fede dot naum at gmail dot com
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 
#include 

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



[Bug c/36914] va_list is treatead as an array when complied in 64bits

2008-07-23 Thread fede dot naum at gmail dot com


--- Comment #1 from fede dot naum at gmail dot com  2008-07-24 05:04 ---
Created an attachment (id=15946)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15946&action=view)
source file

The source file containing the piece of code that is not able to compile in
64bits


-- 


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



[Bug c/36914] va_list is treatead as an array when complied in 64bits

2008-07-23 Thread fede dot naum at gmail dot com


--- Comment #2 from fede dot naum at gmail dot com  2008-07-24 05:06 ---
Created an attachment (id=15947)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15947&action=view)
Preprocessed file  test1.i

The preprocessed file after running
gcc -v -save-temps -m64 -Wall test1.c -o test1.o


-- 


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