https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117658
--- Comment #1 from accelerator0099 at gmail dot com ---
main.cc:
import std;
import pr;
int main() {
std::printf("%d\n",
pr::alias_printable<std::remove_cvref_t<decltype("123")>>);
}
pr.cc:
module;
import std;
namespace pr {
struct alias_t {};
constexpr alias_t alias;
template<class T>
concept alias_printable = requires (T&& t) { print(alias, std::forward<T>(t));
};
template<class A>
requires std::is_array_v<A>
inline void print(alias_t, A&& a) {
std::puts(std::forward<A>(a));
}
}
export module pr;
export namespace pr {
using pr::alias_printable;
}
Compile with:
$ g++ -fmodules-ts -std=c++23 -O3 -c /usr/include/c++/15.0.0/bits/std.cc
$ g++ -fmodules-ts -std=c++23 -O3 -c pr.cc
$ g++ -fmodules-ts -std=c++23 -O3 -c main.cc
$ g++ main.o -o m1
And run ./m1, it outputs "0"
However, if we copy the content of pr.cc into main.cc, making main2.cc
main2.cc:
#include <cstdio>
#include <utility>
namespace pr {
struct alias_t {};
constexpr alias_t alias;
template<class T>
concept alias_printable = requires (T&& t) { print(alias, std::forward<T>(t));
};
template<class A>
requires std::is_array_v<A>
inline void print(alias_t, A&& a) {
std::puts(std::forward<A>(a));
}
}
int main() {
std::printf("%d\n",
pr::alias_printable<std::remove_cvref_t<decltype("123")>>);
}
Compile and run with:
$ g++ -std=c++23 -O3 main2.cc -o m2
$ ./m2
You get output "1"
The former outputs 0 and the latter outputs 1
for clang19, both will output 1