This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/50818] va_list is filled incorrectly in functions with ms_abi attribute on amd64
- From: "steven.shi at intel dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 16 Apr 2016 14:25:33 +0000
- Subject: [Bug target/50818] va_list is filled incorrectly in functions with ms_abi attribute on amd64
- Auto-submitted: auto-generated
- References: <bug-50818-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50818
Steven Shi <steven.shi at intel dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |steven.shi at intel dot com
--- Comment #5 from Steven Shi <steven.shi at intel dot com> ---
Hi Bizjak,
Your Executable testcase cannot really work with -mabi=ms on the command line.
If add a printf() in the while loop to output the sum value as below example,
the testcase will fail again with Segmentation fault even building with with
-mabi=ms.
$ gcc -O2 -mabi=ms pr50818.c
$ ./a.out
Segmentation fault (core dumped)
#include <stdio.h>
int
__attribute__((ms_abi))
foo (int n, ...)
{
__builtin_va_list ap;
int sum = 0;
__builtin_va_start (ap, n);
while (n--) {
sum += __builtin_va_arg (ap, int);
printf("sum = %d\n", sum);
}
__builtin_va_end (ap);
return sum;
}
int main ()
{
int res = foo (10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
if (res != 55)
__builtin_abort ();
return 0;
}