<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 --- - compiler warning padding lambda"
   href="https://llvm.org/bugs/show_bug.cgi?id=31709">31709</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>compiler warning padding lambda
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </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>C++11
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>nivek.research@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The clang compiler may warn that lambda's are padded

# clang++ -std=c++11 -stdlib=libc++ -Weverything -Wno-c++98-compat main.cpp
main.cpp:22:13: warning: padding class '(lambda at main.cpp:20:45)' with 4
bytes to align anonymous bit-field [-Wpadded]
            document->prepare();
            ^
1 warning generated.

I believe one no control over how the compiler stores the state for the lambda
so I believe the warning should not be shown.

#include <cstdint>
#include <functional>

class Document {
public:
    bool unlock(void) { return true; }

    void prepare(void) {}
    void perform(void) {}
};

uint32_t GetCurrentEventKeyModifiers(void);

void UnlockDocumentAndCallFunction(Document* const inDocument,
std::function<void(void)> const inFunction);

int main() {
    Document* const document = new Document();
    uint32_t const modifiers = GetCurrentEventKeyModifiers();
    UnlockDocumentAndCallFunction(document, [=]() {
        if (modifiers & 1) {
            document->prepare();
        }
        document->perform();
    });
    delete document;
    return 0;
}

uint32_t GetCurrentEventKeyModifiers(void) {
    return 1;
}

void UnlockDocumentAndCallFunction(Document* const inDocument,
std::function<void(void)> const inFunction) {
    if (inDocument->unlock()) {
        inFunction();
    }
}</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>