Bugzilla – Bug 144693
gcc fails with suse 10.0.42
Last modified: 2006-01-27 22:27:52 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); }
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 ...
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.
Created attachment 64717 [details] overview of proposed icons
Comment on attachment 64717 [details] overview of proposed icons sorry, wrong bug for my attachment ;-)
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>
Because the "real" type of valist is defined by the ABI which varies between different architectures. You cannot have a function returning valist.