Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Compiler Warning (level 4) C4764

Error Message

Cannot align catch objects to greater than 16 bytes

An alignment greater than 16 was specified, but on some platforms, if the function throws an exception, the stack will force an alignment of not greater than 16.

Example

The following sample generates C4764:

// C4764.cpp
// compile with: /W4 /EHsc
// processor: x64 IPF
#include <stdio.h>

class A 
{
public:
    int x;
};

typedef __declspec(align(32)) A ALIGNEDA;

int main() 
{
    ALIGNEDA a;
    try 
    {
        a.x = 15;
        throw a;
    }
    catch (ALIGNEDA b) // can’t align b to > 16 bytes
    {
        printf_s("%d\n", b.x);
    }
}   // C4764

Community Additions

ADD
Show:
© 2015 Microsoft