-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[C++20] [Modules] static function used in template function in C++-20 module not found #78173
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
Comments
@llvm/issue-subscribers-clang-modules Author: None (ZhalgasFromMSU)
Hi!
NB: Imagine, that I have a // header.hpp
#pragma once
static inline int foo_header(int x) {
return x;
} And this function is used in a template function // module.cpp
module;
#include "header.hpp"
export module Mod;
export template<typename T>
T foo_module(T x) {
return foo_header(x);
} Now I want to use latter in my // main.cpp
import Mod;
int main() {
int x = foo_module(5);
return 0;
} However, clang falsely claims, that there is no matching function
Here are some observation, based on which, I make an assumption that this is a clang bug:
// module.cpp
export template<typename T>
T foo_module(T x) {
return foo_header(static_cast<int>(x));
}
Based on those observations, I could assume that body of |
In fact, the reproducer here is incorrect. We can find the wording and example in [basic.link/p14] to [basic.link/p19]. Then However, this is not supported in clang yet. So the diagnostic is not clear too. @iains has patch for it. But I just wondered that, we may implement the semantics naturally by not emitting static declarations into the reduced BMI naturally. |
Hi!
NB:
Here is a sample project, depicting the problem: https://godbolt.org/z/neo8M8orM
Imagine, that I have a
static inline
functionfoo_header
, defined in some header:And this function is used in a template function
foo_module
in some module:Now I want to use latter in my
main.cpp
:However, clang falsely claims, that there is no matching function
foo_header
:Here are some observation, based on which, I make an assumption that this is a clang bug:
T
toint
like this:static
fromfoo_header
function declarationBased on those observations, I could assume that body of
foo_module
template function gets compiled in different translation unit, from where header was included, and thereforestatic
specifier onfoo_header
hides this functionThe text was updated successfully, but these errors were encountered: