<html>
    <head>
      <base href="https://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 --- - WebAssembly miscompiles global structs with multiple data members"
   href="https://llvm.org/bugs/show_bug.cgi?id=25931">25931</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>WebAssembly miscompiles global structs with multiple data members
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

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

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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>Common Code Generator Code
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jfb@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>(filing under lib/CodeGen, since we don't have a component for WebAssembly at
the moment)

The following GCC torture test:
 
<a href="https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/gcc.c-torture/execute/20010924-1.c">https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/gcc.c-torture/execute/20010924-1.c</a>

Has the following code:

struct {
  char a1c;
  char *a1p;
} a1 = {
  '4',
  "62"
};

struct {
  char a2c;
  char a2p[2];
} a2 = {
  'v',
  "cq"
};

/* The tests.  */
struct {
  char a3c;
  char a3p[];
} a3 = {
  'o',
  "wx"
};

struct {
  char a4c;
  char a4p[];
} a4 = {
  '9',
  { 'e', 'b' }
};


Which WebAssembly's backend miscompiles as:

.str:
    .asciz    "62"
    .size    .str, 3

    .type    a1,@object              # @a1
    .globl    a1
    .align    2
a1:
    .int8    52                      # 0x34
    .zero    3
    .int32    .str
    .size    a1, 8

    .type    a2,@object              # @a2
    .globl    a2
a2:
    .int8    118                     # 0x76
    .ascii    "cq"
    .size    a2, 3

    .type    a3,@object              # @a3
    .globl    a3
a3:
    .int8    111                     # 0x6f
    .asciz    "wx"
    .size    a3, 4

    .type    a4,@object              # @a4
    .globl    a4
a4:
    .int8    57                      # 0x39
    .ascii    "eb"
    .size    a4, 3


Note the missing initialization (but surprisingly, correct size!).</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>