MSVC accepts lambda with deleted parameterized ctor while GCC and Clang rejects
10:32 29 Jan 2026

I wrote the following program that is accepted by msvc but rejected by both gcc and clang. I want to know what is the standard compliant behavior here. Live Demo


struct C
{
  C(int) = delete;
  C(){};
};

decltype([b = C(3)](){ return 4;}()) var; //msvc OK but gcc and clang rejects

int main()
{

} 

Sidenote

Note also that decltype([C(3)](){ return 4;}()) var2; is accepted by all compilers but decltype([b=C(3)](){ return 4;}()) var2; is accpeted by only msvc and rejected by gcc and clang.

c++ lambda language-lawyer