[LLVMbugs] [Bug 10552] New: Struct Allocation / Return Bug

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Aug 1 18:37:49 PDT 2011


           Summary: Struct Allocation / Return Bug
           Product: dragonegg
           Version: 2.7
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: New Bugs
        AssignedTo: baldrick at free.fr
        ReportedBy: bprosnitz at gmail.com
                CC: llvmbugs at cs.uiuc.edu

Consider the following short program:

struct S1 {
   unsigned char  f0;
   volatile unsigned short  f1;
   short  f2;

struct S1  func_9(unsigned short  a)
  struct S1 b;
  b.f0 = 1;
  b.f1 = a;
  b.f2 = -4;
  return b;

int main (void)
    struct S1 k = func_9(5);
    printf("f0 = %d\n", k.f0);

In func_9 compiled with dragonegg 2.7,

5 bytes are allocated for struct S1 b (%memtmp2) with the instruction:
%memtmp2 = alloca %"struct S1"

Yet, 8 bytes are accessed when it is being returned:
  %retval = load i64* %22                        
  ret i64 %retval

In some interpreters like klee, this causes a crash.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list