Please refer to this previous issue I posted, as the problem is very related. This issue was resolved, as it appeared to be fixed in the most recent clang version. However, it is still causing problems with the linker.
I can only assume that the problem stems from how the symbols are named by clang, and that the full specialization of a method with constraints is being named inconsistently between the declaration and implementation.
This inconsistency also appears to only present itself in between different translation units.
Minimal example of failure:
To compile:
clang++ -std=c++20 -c fail.cpp -o fail.oclang++ -std=c++20 fail.o main.cpp
fail.h
#pragma once
#include <concepts>
template <typename T>
struct test
{
void method() requires(std::floating_point<T>);
};
PS: Although I wasn't able to replicate this by adding "-g" to this minimal example, this problem only presented itself in the release build of my project.
EDIT:
Here's the output:
Undefined symbols for architecture arm64:
"test<double>::method() requires std::floating_point<T>", referenced from:
_main in main-2929fe.o
ld: symbol(s) not found for architecture arm64
Please refer to [this](https://github.com/llvm/llvm-project/issues/102548) previous issue I posted, as the problem is very related. This issue was resolved, as it appeared to be fixed in the most recent clang version. However, it is still causing problems with the linker.
I can only assume that the problem stems from how the symbols are named by clang, and that the full specialization of a method with constraints is being named inconsistently between the declaration and implementation.
This inconsistency also appears to only present itself in between different translation units.
Minimal example of failure:
To compile:
`clang++ -std=c++20 -c fail.cpp -o fail.o`
`clang++ -std=c++20 fail.o main.cpp`
**fail.h**
```
#pragma once
#include <concepts>
template <typename T>
struct test
{
void method() requires(std::floating_point<T>);
};
```
**fail.cpp**
```
#include "fail.h"
#include <iostream>
template <>
void test<double>::method()
{
std::cout << "Sucess\n";
}
```
**main.cpp**
```
#include <iostream>
#include "fail.h"
int main()
{
test<double> t;
t.method();
}
```
This compiles and links in gcc, but fails to compile using clang.
```
clang++ --version
clang version 20.0.0git (https://github.com/llvm/llvm-project.git 101cf540e698529d3dd899d00111bcb654a3c12b)
Target: arm64-apple-darwin23.5.0
Thread model: posix
InstalledDir: /usr/local/bin
```
PS: Although I wasn't able to replicate this by adding "-g" to this minimal example, this problem only presented itself in the release build of my project.
EDIT:
Here's the output:
```
Undefined symbols for architecture arm64:
"test<double>::method() requires std::floating_point<T>", referenced from:
_main in main-2929fe.o
ld: symbol(s) not found for architecture arm64
```
Please refer to [this](https://github.com/llvm/llvm-project/issues/102548) previous issue I posted, as the problem is very related. This issue was resolved, as it appeared to be fixed in the most recent clang version. However, it is still causing problems with the linker.
I can only assume that the problem stems from how the symbols are named by clang, and that the full specialization of a method with constraints is being named inconsistently between the declaration and implementation.
This inconsistency also appears to only present itself in between different translation units.
Minimal example of failure:
To compile:
`clang++ -std=c++20 -c fail.cpp -o fail.o`
`clang++ -std=c++20 fail.o main.cpp`
**fail.h**
```
#pragma once
#include <concepts>
template <typename T>
struct test
{
void method() requires(std::floating_point<T>);
};
```
**fail.cpp**
```
#include "fail.h"
#include <iostream>
template <>
void test<double>::method()
{
std::cout << "Sucess\n";
}
```
**main.cpp**
```
#include <iostream>
#include "fail.h"
int main()
{
test<double> t;
t.method();
}
```
This compiles and links in gcc, but fails to compile using clang.
```
clang++ --version
clang version 20.0.0git (https://github.com/llvm/llvm-project.git 101cf540e698529d3dd899d00111bcb654a3c12b)
Target: arm64-apple-darwin23.5.0
Thread model: posix
InstalledDir: /usr/local/bin
```
PS: Although I wasn't able to replicate this by adding "-g" to this minimal example, this problem only presented itself in the release build of my project.
EDIT:
Here's the output:
```
Undefined symbols for architecture arm64:
"test<double>::method() requires std::floating_point<T>", referenced from:
_main in main-2929fe.o
ld: symbol(s) not found for architecture arm64
```
Please refer to this previous issue I posted, as the problem is very related. This issue was resolved, as it appeared to be fixed in the most recent clang version. However, it is still causing problems with the linker.
I can only assume that the problem stems from how the symbols are named by clang, and that the full specialization of a method with constraints is being named inconsistently between the declaration and implementation.
This inconsistency also appears to only present itself in between different translation units.
Minimal example of failure: To compile:
clang++ -std=c++20 -c fail.cpp -o fail.o
clang++ -std=c++20 fail.o main.cpp
fail.h
fail.cpp
main.cpp
This compiles and links in gcc, but fails to compile using clang.
PS: Although I wasn't able to replicate this by adding "-g" to this minimal example, this problem only presented itself in the release build of my project.
EDIT: Here's the output: