[Bug c/36255] New: -fstrict-aliasing breaks __builtin_va_args

2008-05-17 Thread juanjose dot garciaripoll at gmail dot com
When using -fstrict-aliasing the function LC1_f15 below gets miscompiled. More
precisely, the va_list object is only partially assigned. The system fails to
set the frame size or something similar. In the assembler I see

/*  local function %F15   */
static cl_object LC1_f15(cl_narg narg, volatile cl_object *lex0, ...)
{
cl_object value0;
cl_object V1;
va_list args; va_start(args,lex0);
   0:   48 8d 44 24 08  lea0x8(%rsp),%rax
   5:   48 89 44 24 e0  mov%rax,-0x20(%rsp)
if (narg  1) {
   a:   ba 00 00 00 00  mov$0x0,%edx
   f:   48 85 fftest   %rdi,%rdi
  12:   7e 1a   jle2e LC1_f15+0x2e
  V1=0;
} else {
  V1= va_arg(args,cl_object);
  14:   8b 44 24 d8 mov-0x28(%rsp),%eax
  18:   83 f8 30cmp$0x30,%eax

Here we are reading -0x28(%rsp) which has not been set. The same code, with gcc
4.1 produces an assignment mov 0x10,-0x28(%rsp) that makes things right. The
preprocessed example follows.

# 1 /usr/lib/gcc/x86_64-linux-gnu/4.2.3/include/stdarg.h 1 3 4
# 43 /usr/lib/gcc/x86_64-linux-gnu/4.2.3/include/stdarg.h 3 4
typedef __builtin_va_list __gnuc_va_list;
# 105 /usr/lib/gcc/x86_64-linux-gnu/4.2.3/include/stdarg.h 3 4
typedef __gnuc_va_list va_list;

typedef long cl_fixnum;
typedef unsigned long cl_index;
typedef union cl_lispunion *cl_object;
typedef cl_fixnum cl_narg;

struct ecl_singlefloat {
 float SFVAL;
};

struct ecl_stack_frame {
 cl_object *bottom;
 cl_object *top;
 cl_object *stack;
};

union cl_lispunion {
 struct ecl_singlefloat SF;
 struct ecl_stack_frame frame;
};

struct cl_env_struct2 {
 cl_index nvalues;
 cl_object values[64];
};

extern struct cl_env_struct2 cl_env2;


static cl_object LC1_f15(cl_narg narg, volatile cl_object *lex0, ...)
{
 cl_object value0;
 cl_object V1;
 va_list args; __builtin_va_start(args,lex0);
 if (narg  1) {
   V1=0;
 } else {
  V1= __builtin_va_arg(args,cl_object);
 }
 value0=V1; cl_env2.nvalues=1;
 return value0;
}


cl_object LC2__g147(cl_object V1, cl_object V2, cl_object V3)
{
 cl_object T0;
 volatile cl_object lex0[1];
 cl_object value0;
 {
 lex0[0]= V3;
 value0=LC1_f15(1,lex0,MAKE_FIXNUM(-2688612)) ;
 return value0;
}}


-- 
   Summary: -fstrict-aliasing breaks __builtin_va_args
   Product: gcc
   Version: 4.2.3
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: juanjose dot garciaripoll at gmail dot com
 GCC build triplet: x86_64-linux-gnu
  GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu


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



[Bug c/36255] -fstrict-aliasing breaks __builtin_va_args

2008-05-17 Thread juanjose dot garciaripoll at gmail dot com


--- Comment #2 from juanjose dot garciaripoll at gmail dot com  2008-05-17 
13:27 ---
Created an attachment (id=15649)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15649action=view)
Files for test case (simple.c 1/3)


-- 


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



[Bug c/36255] -fstrict-aliasing breaks __builtin_va_args

2008-05-17 Thread juanjose dot garciaripoll at gmail dot com


--- Comment #3 from juanjose dot garciaripoll at gmail dot com  2008-05-17 
13:28 ---
Created an attachment (id=15650)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15650action=view)
Files for test case (simple.h 2/3)


-- 


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



[Bug c/36255] -fstrict-aliasing breaks __builtin_va_args

2008-05-17 Thread juanjose dot garciaripoll at gmail dot com


--- Comment #4 from juanjose dot garciaripoll at gmail dot com  2008-05-17 
13:29 ---
Created an attachment (id=15651)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15651action=view)
Files for test case (main.c 3/3)


-- 


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



[Bug c/36255] -fstrict-aliasing breaks __builtin_va_args

2008-05-17 Thread juanjose dot garciaripoll at gmail dot com


--- Comment #5 from juanjose dot garciaripoll at gmail dot com  2008-05-17 
13:32 ---
I uploaded the program that fails if the GCC miscompiles the file simple.c
However, I had to split the test case into two different files, for otherwise
GCC inlines the offending function and the error is not produced.

I compiled the files separately, with and without -fstrict-aliasing, and it
only fails in the first case.


-- 


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