Closed
Description
I believe this code should not produce the static assertion failure:
//--- lambda.h
#pragma once
inline auto cmp = [](auto l, auto r) {
return l < r;
};
//--- A.cppm
module;
#include "lambda.h"
export module A;
export auto c1 = cmp;
export using ::cmp;
//--- B.cppm
module;
#include "lambda.h"
export module B;
export auto c2 = cmp;
export using ::cmp;
//--- use.cppm
module;
export module use;
import A;
import B;
static_assert(__is_same(decltype(c1), decltype(c2))); // should succeed.
auto x = cmp; // cmp must not be ambiguous,
// Build with:
// clang++ -std=c++20 --precompile -o A.pcm A.cppm
// clang++ -std=c++20 --precompile -o B.pcm B.cppm
// clang++ -std=c++20 -fprebuilt-module-path=. use.cppm
As the lambda meets all requirements specified in basic.def.odr and cmp
is declared inline. I.e. this should be no different from explicit class declaration from lambda.
However, the static assertion currently fails and the use of 'cmp' produces an "ambiguous reference" error.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done