<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 --- - -Wpacked warns even though packed structure has different size/memory layout"
   href="http://llvm.org/bugs/show_bug.cgi?id=18132">18132</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>-Wpacked warns even though packed structure has different size/memory layout
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.3
          </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>Frontend
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>hanauska@equinux.com
          </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>Consider the following rather simple code snippet:

----- packed.c ----

#include <stdint.h>
#include <stdio.h>

struct S1 {
    uint16_t addr;
    uint32_t value;
};

struct S2 {
    uint16_t addr;
    uint32_t value;
} __attribute__((packed));


int main (int argc, char ** argv) {
    struct S1 s1;
    struct S2 s2;

    printf("%zu - %zu\n", sizeof(s1), sizeof(s2));
    return 0;
};

-------------------

Compiling and running this code should produce the following output on a 32/64
bit system:

8 - 6

(I think it may be 6 - 6 on a 16 bit system)

So whether the struct is packed or not *DOES* make a difference here. Yet,
compiling the code above using "-Wpacked", I get the following:

packed.c:10:11: warning: packed attribute is unnecessary for 'addr' [-Wpacked]
        uint16_t addr;
                 ^

This doesn't seem correct to me. As I understand "-Wpacked", it should only
produce a warning if the presence of the packed attribute has no influence on
the structure size and thus also no influence on the relative memory layout of
the fields within the structure.</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>