<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - possible wrongful crash from undefined sanitizer"
   href="http://llvm.org/bugs/show_bug.cgi?id=17635">17635</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>possible wrongful crash from undefined sanitizer
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>regehr@cs.utah.edu
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I can't see anything wrong with the code below yet it throws an illegal
instruction.  Note that the packed and unpacked structs have the same field
offsets in 32-bit mode.

$ clang -m32 -O -fsanitize=undefined main.c ; ./a.out 
24 23
Illegal instruction

$ cat main.c
#include <stdio.h>
#include <assert.h>

struct s2 {
  long long f0;
  long f1;
  unsigned int f2;
  unsigned long f3;
  short f4;
  unsigned char f5;
};

#pragma pack (1)
struct s2_packed {
  long long f0;
  long f1;
  unsigned int f2;
  unsigned long f3;
  short f4;
  unsigned char f5;
};
#pragma pack ()

void copy (char* out, char* in)
{
  int i;
  for (i = 0; i < 23; i++) out[i] = in[i];
}

int main (void)
{
  struct s2 topack1 = {48098, 3948348, 234985, 32034849, 3432, 'u'};
  struct s2_packed packed1;
  printf ("%d %d\n", sizeof (struct s2), sizeof (struct s2_packed));
  copy((char*)&packed1, (char*)&topack1);
  assert(topack1.f0 == packed1.f0);
  assert(topack1.f1 == packed1.f1);
  assert(topack1.f2 == packed1.f2);
  assert(topack1.f3 == packed1.f3);
  assert(topack1.f4 == packed1.f4);
  assert(topack1.f5 == packed1.f5);
  printf("Tests Complete.\n");
  return 0;
}

$ clang -v
clang version 3.4 (trunk 193086)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.7.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.3
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>