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

Module STD : Another error with crtdbg header #4667

Closed
Cazayus opened this issue May 10, 2024 · 1 comment
Closed

Module STD : Another error with crtdbg header #4667

Cazayus opened this issue May 10, 2024 · 1 comment
Labels
duplicate This issue or pull request already exists modules C++23 modules, C++20 header units

Comments

@Cazayus
Copy link

Cazayus commented May 10, 2024

Describe the bug

It is possible to work around the issue #4666 with a #define, but the following code still fails to compile with another error.
Seemed worth reporting separately just in case.

Command-line test case

C:\Temp>type repro.cpp
import std;
#define align_val_t ignore_align_val_t // only here to silence the error of issue #4666

void mainNew()
{
    std::pmr::memory_resource* m_upstream;
    m_upstream->allocate(0);
}

#include <crtdbg.h>

C:\Temp>cl.exe /std:c++latest /EHsc /nologo /c .\repro.cpp

C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\vcruntime_new.h(162): error C2084: function 'void *operator new(size_t,void *) noexcept' already has a body
C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\vcruntime_new.h(162): note: see previous definition of 'operator new'
C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\vcruntime_new.h(162): error C3615: constexpr function 'operator new' cannot result in a constant expression
C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33807\include\vcruntime_new.h(162): note: failure was caused by control reaching the end of a constexpr function

Expected behavior

It should compile but does not

STL version

    Microsoft Visual Studio Community 2022
    Version 17.10.0 Preview 7.0
@StephanTLavavej StephanTLavavej added duplicate This issue or pull request already exists modules C++23 modules, C++20 header units labels May 10, 2024
@StephanTLavavej
Copy link
Member

Thanks for the report - this is a duplicate of #4666. While the error is different (::operator new instead of std::align_val_t), the root cause is the same - <crtdbg.h> drags in VCRuntime, and VCRuntime has to export a bit of Standard Library machinery, so this is the import-before-include scenario that's blocked by our implementation bug/limitation.

I appreciate the report even though it turned out to be a duplicate (sometimes similar-looking bugs are actually distinct).

@StephanTLavavej StephanTLavavej closed this as not planned Won't fix, can't repro, duplicate, stale May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists modules C++23 modules, C++20 header units
Projects
None yet
Development

No branches or pull requests

2 participants