Bug 144693

Summary: gcc fails with suse 10.0.42
Product: [openSUSE] SUSE Linux 10.1 Reporter: Jos Huisken <jos>
Component: DevelopmentAssignee: Philipp Thomas <pth>
Status: RESOLVED INVALID QA Contact: E-mail List <qa-bugs>
Severity: Major    
Priority: P5 - None CC: matz, meissner, rguenther
Version: Alpha 4   
Target Milestone: ---   
Hardware: x86-64   
OS: SuSE Linux 10.0   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: overview of proposed icons
Artificial example, no real code

Description Jos Huisken 2006-01-22 22:26:49 UTC
Hi,

I tried to compile on a 64-bit athlon.
With 'gcc' it fails, with 'gcc -m32' compilation passes.
Resulting error:

t.c:4: error: ‘function’ declared as function returning an array
t.c:8: error: ‘function’ declared as function returning an array
t.c: In function ‘function’:
t.c:9: warning: return makes integer from pointer without a cast


Preprocessed c-code (the same for -m32 and without -m32):

# 1 "t.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "t.c"

# 1 "/usr/lib64/gcc/x86_64-suse-linux/4.1.0/include/stdarg.h" 1 3 4
# 43 "/usr/lib64/gcc/x86_64-suse-linux/4.1.0/include/stdarg.h" 3 4
typedef __builtin_va_list __gnuc_va_list;
# 105 "/usr/lib64/gcc/x86_64-suse-linux/4.1.0/include/stdarg.h" 3 4
typedef __gnuc_va_list va_list;
# 3 "t.c" 2

va_list function(va_list args);


va_list function(va_list args)
{
    return(args);
}


int main(const int argc, const char *argv[])
{
    return(0);
}


Actual C-code:

#include <stdarg.h>

va_list function(va_list args);


va_list function(va_list args)
{
    return(args);
}


int main(const int argc, const char *argv[])
{
    return(0);
}
Comment 1 Marcus Meissner 2006-01-23 08:59:33 UTC
what you do is not possible, va_list is more of a state than a variable.

also the stackarguments are gone on return, so how do you want to return them.

depending on what you really want to do , function() should retrieve the va_list arguments and store them in an malloced array ...
Comment 2 Richard Biener 2006-01-23 10:19:50 UTC
No way in earth it is possible or allowed to do anything that looks like your code.  The only thing that is allowed is to _pass_ a va_list to another function
(like vprintf and friends expect one).  Returning a va_list does not make sense
and is generally impossible to implement.  Also don't try storing the va_list
itself somewhere in memory, this will fail, too.  Marcus probably thinks of
retrieving the args using va_arg and storing them _by value_ somewhere in memory.
Comment 3 Christian Boltz 2006-01-24 12:48:26 UTC
Created attachment 64717 [details]
overview of proposed icons
Comment 4 Christian Boltz 2006-01-24 16:20:21 UTC
Comment on attachment 64717 [details]
overview of proposed icons

sorry, wrong bug for my attachment ;-)
Comment 5 Jos Huisken 2006-01-27 20:29:24 UTC
Created attachment 65517 [details]
Artificial example, no real code

Hi,

Why does the following happen on a athlon64?
With -m32 the compilation passes correctly...

huisken@joel:/tmp> gcc -c t.c
t.c:4: error: ‘function’ declared as function returning an array
t.c: In function ‘function’:
t.c:5: warning: return makes integer from pointer without a cast
huisken@joel:/tmp> gcc -m32 -c t.c
huisken@joel:/tmp>
Comment 6 Richard Biener 2006-01-27 22:27:52 UTC
Because the "real" type of valist is defined by the ABI which varies between different architectures.  You cannot have a function returning valist.