VS2017 15.8 std::aligned_storage error

Hi,

I upgraded to vs2017 15.8 last night and now my builds have the following error:

Severity Code Description Project File Line Suppression State
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. _WAF_ D:\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\type_traits 1271

I am currently in the process of downgrading to 15.7.6 but was wondering if the lumberyard team were aware of this yet and whether there was a fix yet.

@Techtime,

Per the VS2017 15.8 message: The idea is to define one of the following two options for the preprocessor:
_DISABLE_EXTENDED_ALIGNED_STORAGE
or
_ENABLE_EXTENDED_ALIGNED_STORAGE

_ENABLE_EXTENDED_ALIGNED_STORAGE is what I chose, because of this test case results: https://developercommunity.visualstudio.com/content/problem/274945/stdmake-shared-is-not-honouring-alignment-of-a.html

Now, the trick is how to add _ENABLE_EXTENDED_ALIGNED_STORAGE to the preprocessor definitions for ALL of the projects of the Lumberyard VS2017 solution?

My hack was to edit: …\lumberyard\dev\Tools\build\waf-1.7.13\lmbrwaflib\cryengine_modules.py
as follows: The magic line is: " additional_defines.append(‘_ENABLE_EXTENDED_ALIGNED_STORAGE’)"


    def apply_cryengine_module_defines(ctx, kw):
additional_defines = ctx.get_binfolder_defines()
ctx.add_aws_native_sdk_platform_defines(additional_defines)
additional_defines.append('LY_BUILD={}'.format(ctx.get_lumberyard_build()))
additional_defines.append('_ENABLE_EXTENDED_ALIGNED_STORAGE')
append_kw_entry(kw, 'defines', additional_defines)

I saved the file, deleted the “Solutions” directory: .\lumberyard\dev\Solutions\

And ran again “lmbr_waf configure” from the CMD.

Open the newly generated solution file and rebuild.
…\lumberyard\dev\Solutions\LumberyardSDK_vs15.sln

nice solution! I’ve already downgraded to 15.7.6 and can’t be bothered to upgrade yet. I assume a future lumberyard release will use this fix.

Hi @YharnamHunter,

Thanks for reporting this issue and workaround! We have fixed the issue in our internal build, however we updated the dev\Tools\build\waf-1.7.13\lmbrwaflib\compile_rules_win_x64_win_x64_vs2017.py line 29 to be this:

v['DEFINES'] += ['_WIN32', '_WIN64', 'NOMINMAX', '_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING', '**_ENABLE_EXTENDED_ALIGNED_STORAGE**']

FYI, this is not necessarily going to be the final fix, but is more likely to be in the next official release than the workaround you have.