-
Notifications
You must be signed in to change notification settings - Fork 264
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
c++17 inline variables with clang cause a linker error in ndk 15c #538
Comments
example? |
havent tried to see if a smaller project succeeds, but our current project is cross-platform with ios, and it works in xcode 8+. small enough snippet to get an idea is: MemoryAllocator.h: struct MemoryAllocator
{
...
};
ListRef<byte> AllocateHeap() noexcept;
namespace global
{
#if __cplusplus >= 201406
inline MemoryAllocator _Allocator{AllocateHeap()};
inline auto& Allocator() noexcept
{
return _Allocator;
}
#else
inline auto& Allocator() noexcept
{
static MemoryAllocator allocator{AllocateHeap()};
return allocator;
}
#endif
} |
Altering your sample so it can actually compile: struct MemoryAllocator {
MemoryAllocator() {}
};
inline MemoryAllocator _Allocator{};
inline auto& Allocator() noexcept {
return _Allocator;
} Builds fine for me with |
your test code probably needs to use the allocator in multiple cpp files, or else it will completely get stripped out |
To be blunt, we have plenty of other bugs that need our attention from people that did provide repro cases. It wouldn't be fair to them to give priority to people that put less effort into their bug reports. |
also are you sure you went through a full build? because i can't link with -std=c++1z on regardless because of #421. im building with c++14, and ignoring the warning of -Wc++1z-extensions |
i dont think you went through the full build process because of #421 with -std=c++1z on. regardless, thanks for taking your time, as i also have my own priorities, and can't spend too much time on this stuff. |
Closing since we don't have a test case after five months and I'm guessing this was just a not yet implemented feature in clang. |
just tested on ndk r17-beta1, and i still get linker errors. in my original code, i get "error: undefined reference" to AllocateHeap(), and the constructor of MemoryAllocator. no problems with the _Allocator object. ndk17 has clang 6, which has full support for c++17. apples clang works, and those functions link fine in the c++14 case. project is large and ill see if can find a standalone repro. |
We don't really buave clang 6, we have clang 6 svn, which means we have something between clang 5 and clang 6. Regardless, there's still nothing we can do about this bug without a test case. |
been trying for half the day to try and get a reduced form but i cant repro besides with my exact code in my exact large project. |
it might be fixed in a later svn of clang as they fixed a bunch of inline var stuff since the rev you guys build r17 off of. |
i do know it is at least related to having a non trivial constructor. if remove the constructor and remove and nontrivial member objects, it works |
c++17 inline variables with clang cause a linker error in ndk 15c. They are suppose to be supported since clang 3.9, so 5.0 should definitely work.
windows 64bit, ndk 15c, cmake
The text was updated successfully, but these errors were encountered: