-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[C++20][Modules] Compile Error with static template function. #130057
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
This is somehow like exposing a TU-local (translation-unit-local) entity (and should be consistently rejected when compiling a.cppm if so). See also #112294. |
@llvm/issue-subscribers-clang-modules Author: Jae-Hyuck Park (jaehyuck0103)
Hello. LLVM.
I encountered an incomprehensible compilation error related to a static template function while using C++ modules. EnvironmentUbuntu clang version 21.0.0 (++20250305083430+f4878cb91612-1 Codes// main.cpp
#include "dummy_cuda_runtime.h"
#include <cstdint>
import MyModule;
int main() {
uint16_t *buffer;
cudaMalloc(&buffer, 100 * sizeof(uint16_t)); // No Compile Error
MyClass aaa;
cudaMalloc(&buffer, 100 * sizeof(uint16_t)); // Compile Error
} // a.cppm
module;
#include "dummy_cuda_runtime.h"
#include <cstdint>
export module MyModule;
export class MyClass {
public:
MyClass() {
// If below line is not in constructor, No Compile Error
cudaMalloc(&buffer_, 100 * sizeof(uint16_t));
}
uint16_t *buffer_;
}; // dummy_cuda_runtime.h
template <class T> static void cudaMalloc(T **devPtr, int size) {
// dummy
}
mkdir build
cd build
cmake .. -G Ninja
ninja
|
This is a bug. In main you've already included the static one. Could you test if |
@ChuanqiXu9 |
It didn't expose it. Since the member function in modules are not implicitly inline. So it is fine. |
OK. Reduced BMI is going to be the default. |
Hello. LLVM.
I encountered an incomprehensible compilation error related to a static template function while using C++ modules.
I provide the minimal code below to reproduce the issue.
It's my first bug report to LLVM. Please let me know if there's anything wrong.
Environment
Ubuntu clang version 21.0.0 (++20250305083430+f4878cb91612-1
exp120250305083603.767)Target: x86_64-pc-linux-gnu
Codes
mkdir build cd build cmake .. -G Ninja ninja
The text was updated successfully, but these errors were encountered: