Closed
Description
Given the following valid translation units:
module;
inline auto x = []{};
export module a;
module;
import a;
inline auto x = []{};
export module b;
clang erroneously rejects with
b.cpp:5:13: error: redeclaration of 'x' with a different type: '(lambda at /app/b.cpp:5:17)' vs '(lambda at /app/a.cpp:3:17)'
5 | inline auto x = []{};
| ^
a.cpp:3:13: note: previous definition is here
3 | inline auto x = []{};
| ^
1 error generated.
See it live: https://godbolt.org/z/WxW47zW4v
This is the reduced version of the following reproducer:
module;
#include <compare>
export module a;
module;
import a;
#include <compare>
export module b;
in which clang with libc++ erroneously rejects with
In file included from /app/b.cpp:4:
In file included from /opt/compiler-explorer/clang-assertions-trunk-20240809/bin/../include/c++/v1/compare:156:
/opt/compiler-explorer/clang-assertions-trunk-20240809/bin/../include/c++/v1/__compare/synth_three_way.h:28:45: error: redeclaration of '__synth_three_way' with a different type: 'const std::__1::(lambda at /opt/compiler-explorer/clang-assertions-trunk-20240809/bin/../include/c++/v1/__compare/synth_three_way.h:28:65)' vs 'const std::__1::(lambda at /opt/compiler-explorer/clang-assertions-trunk-20240809/bin/../include/c++/v1/__compare/synth_three_way.h:28:65)'
28 | _LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way = []<class _Tp, class _Up>(const _Tp& __t, const _Up& __u)
| ^
/opt/compiler-explorer/clang-assertions-trunk-20240809/bin/../include/c++/v1/__compare/synth_three_way.h:28:45: note: previous definition is here
28 | _LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way = []<class _Tp, class _Up>(const _Tp& __t, const _Up& __u)
| ^
1 error generated.
See it live: https://godbolt.org/z/4dK717sr4
Looks like the library side of it was reintroduced by d043e4c @H-G-Hristov, @Zingam but I suspect that the clang side of it was never fully fixed. #57222 @ChuanqiXu9 shows a unit test for two modules that just include a header with an inline lambda, but this case of import module that included, followed by include appears to have slipped through.