Description

Visual Studio 2017 15.8 includes a fix to properly handle std::make_shared used with over-aligned types. However, this is a breaking fix and requires the definition of one of two macros to either acknowledge being aware of the fix or disable the fix and return to the previous behavior. The Engine does not appear to define either macro, and there is no clear method for how to define either macro at the project level.

Steps to Reproduce

SETUP:
This repro requires Visual Studio 2017 15.8+.

REPRO:

  1. Create a new Basic Code project.
  2. In the GameModeBase.h file for the new project, add #include <memory> at the top of the file.
  3. In the body of the class, add the following code:
    struct alignas(16) large_aligned
    {
    	int v;
    };
    
    void test()
    {
    	auto blah = std::make_shared<large_aligned>();
    }
    
  4. Build the project in Visual Studio.

RESULT:
The build fails with the following error: error C2338: You've instantiated std::aligned_storage<Len, Align> with an extended alignment (in other words, Align > alignof(max_align_t)). Before VS 2017 15.8, the member type would non-conformingly have an alignment of only alignof(max_align_t). VS 2017 15.8 was fixed to handle this correctly, but the fix inherently changes layout and breaks binary compatibility (only for uses of aligned_storage with extended alignments). Please define either (1) _ENABLE_EXTENDED_ALIGNED_STORAGE to acknowledge that you understand this message and that you actually want a type with an extended alignment, or (2) _DISABLE_EXTENDED_ALIGNED_STORAGE to silence this message and get the old non-conformant behavior.

EXPECTED:
The build completes successfully.

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-63560 in the post.

2
Login to Vote

Fixed
ComponentUE - Foundation - Core
Affects Versions4.19.24.20.24.21
Target Fix4.22
Fix Commit4344760
Main Commit4772220
Release Commit4862694
CreatedAug 30, 2018
ResolvedSep 5, 2018
UpdatedFeb 12, 2019
View Jira Issue