Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<format>: Bogus compiler errors with /presetPadding #2558

Closed
StephanTLavavej opened this issue Feb 10, 2022 · 0 comments · Fixed by #2746
Closed

<format>: Bogus compiler errors with /presetPadding #2558

StephanTLavavej opened this issue Feb 10, 2022 · 0 comments · Fixed by #2746
Labels
bug Something isn't working fixed Something works now, yay! format C++20/23 format

Comments

@StephanTLavavej
Copy link
Member

StephanTLavavej commented Feb 10, 2022

D:\GitHub\STL\out\build\x64>type meow.cpp
#include <iostream>
#include <format>
using namespace std;

int main() {
    cout << format("I have {} cute {} kittens.\n", 1729, "fluffy");
}
D:\GitHub\STL\out\build\x64>cl /EHsc /nologo /W4 /std:c++20 meow.cpp && meow
meow.cpp
I have 1729 cute fluffy kittens.

D:\GitHub\STL\out\build\x64>cl /nologo /? | findstr presetPadding
/presetPadding[-] zero initialize padding for stack based class types

D:\GitHub\STL\out\build\x64>cl /EHsc /nologo /W4 /std:c++20 /presetPadding meow.cpp && meow
meow.cpp
meow.cpp(6): error C7595: 'std::_Basic_format_string<char,int,const char (&)[7]>::_Basic_format_string': call to immediate function is not a constant expression

The root cause is a compiler bug, VSO-1444086 "consteval + /presetPadding error". Reported by @cdacamar, who has asked us to look into a workaround, and provided:

Note: the workaround is to decorate _Basic_format_string with __declspec(no_init_all) like we do for our validator:

template <DiagMessageSort T, typename... Ts>
class __declspec(no_init_all) MessageValidator
@StephanTLavavej StephanTLavavej added bug Something isn't working format C++20/23 format labels Feb 10, 2022
@StephanTLavavej StephanTLavavej added the fixed Something works now, yay! label Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed Something works now, yay! format C++20/23 format
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant