2,119 questions
0
votes
0
answers
63
views
check_ipo_supported returns false on windows when using clang++ provided by MSYS2
On windows, using check_ipo_supported CMake function gives the following results:
compiler
generator
check_ipo_supported
msvc
NMake Makefiles
TRUE
g++ (from MSYS2)
MinGW Makefiles
TRUE
clang++ (from ...
2
votes
1
answer
141
views
Clangd query driver still uses clang source dir
Recently i've been working on some project with GNU arm compiler for C++ project. I've configured clangd to use this compiler with query-driver as clangd documentation recommends. The problem is ...
1
vote
1
answer
51
views
How can I correlate a clang::CXXMethodDecl with documentation comments that are in the header?
I am learning to work with the clang AST while developing a refactoring tool.
I'm using a clang::ast_matchers::dynamic::DynTypedMatcher created using the clang::ast_matchers::dynamic::Parser::...
-5
votes
1
answer
207
views
How do I get my existing MSVC project to compile with the Visual Studio 2022 Clang compiler?
I have an existing c++ project that compiles fine with msvc, and I'm trying to get it to compile in Visual Studio 2022 with LLVM (clang-cl). At the moment I'm using C++ Language Standard Preview ISO C+...
2
votes
3
answers
239
views
How to detect C++20 mode of compilation?
When compiling my program using a recent version of OpenVDB library by Clang in C++20 mode, I get the error:
error: use of the 'assume' attribute is a C++23 extension
I see that it is due to the ...
14
votes
2
answers
322
views
Is clang broken with `-std=c++20` and `-Wdtor-name`
Consider this simple code.
struct Foo {
template <typename T>
struct Bar {
~Bar();
};
};
with the out-of-line implementation
template <typename T>
Foo::Bar<T>::~...
1
vote
1
answer
107
views
How to rebuild Clang 16.0.0 on Ubuntu 22.04 so it links with `libtinfo6` instead of `libtinfo5`?
I’m working on a legacy C++ codebase that ships with its own Clang 16 inside a thirdparty/llvm-build-16 folder. On our new Ubuntu 22.04 build system, this bundled compiler fails to run because it ...
3
votes
1
answer
114
views
Why does Clang fail to compile, but GCC succeeds, with identical ~/.zshrc configuration?
On my Apple M2 (ARM64-apple-darwin) I have the following C++ code stored in the file hello_world.cpp in some directory called code.
I want to be able to compile it using both Clang and GCC, but ...
0
votes
0
answers
34
views
How to combine PyVarObject_HEAD_INIT and designated initializers?
In my own "native" Python module I declare a new type this way:
PyTypeObject calculatorType = {
PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "My.Calculator",
.tp_basicsize ...
2
votes
1
answer
109
views
How to put source information in the debug symbols without embedding the full sources on Linux?
MSVC has a very useful flag /SOURCELINK. This allows you to tell where in your versioning system the sources are stored, such that they can be downloaded.
For example: (Also holds for C++)
{
"...
5
votes
2
answers
161
views
Is this assignment to brace-enclosed string constant really illegal in C++?
I am porting a large codebase from Linux/g++ to MacOS/Clang. I hit this compiler error in multiple places in Clang (where g++ builds successfully and does the right thing at run time):
error: ...
0
votes
1
answer
189
views
Xcode 26 clang doesn't support sized deallocation
The clang compiler shipping with Xcode 26 does not support sized deallocation:
void* p = operator new(100);
// [...]
operator delete(p, 100); // error: no matching function for call to 'operator ...
1
vote
0
answers
39
views
Can HWASAN support runtime suppressions?
The design document for Hardware-assisted AddressSanitizer does not document whether or not runtime suppressions are possible using the HWASAN_OPTIONS environment variable.
Assuming a program compiled ...
0
votes
1
answer
241
views
Building .NET MAUI app for iOS fails with "clang++ exited with code 1"
I am developing a mobile app in .NET Maui with .NET 8.0 for both Android and iOS using the latest Release of Visual Studio 2022 and a Windows PC. Everything worked very well until this week. I can no ...
2
votes
2
answers
114
views
Can clang -ffast-math optimize away comparison between quiet_NaN and float?
I noticed that the following program optimizes to no instructions at all on recent versions of clang, with -ffast-math and -O1 and higher:
#include <cassert>
#include <limits>
int main() {...
0
votes
1
answer
110
views
Clang negative threading warning not compiling
I am trying to get Negative Capabilities working, as described in the link. I have the following code, which is based on the example in the link provided. (I changed their example mutex, Mutex, which ...
-3
votes
1
answer
127
views
Why does this program trap, kill or result in a segmentation fault? [duplicate]
Platform: aarch64, android 14, clang 20.1.6 (latest version), llvm 20.1.6, kernel 5.4.254-qgki-ga443
Code:
int start_game(void) {
}
int main(int argc, char **argv) {
start_game();
}
Problem: My ...
1
vote
1
answer
169
views
How to disable all SIMD related feature macros in clang?
By default, clang defines some SIMD related macros:
~ $ 0 clang++ -dM -E -x c /dev/null | grep -i sse
#define __SSE2_MATH__ 1
#define __SSE2__ 1
#define __SSE_MATH__ 1
#define __SSE__ 1
These can be ...
0
votes
0
answers
20
views
Getting all exception specifications in Clang
I am working on a program that outputs a C++ AST to a form that can be injested by the Rocq theorem prover. For many things, this works well, but Clang seems to compute some information lazily and ...
1
vote
0
answers
226
views
Xcode ScanDependencies failures building React Native iOS app (com.apple.compilers.llvm.clang.1_0.compiler)
I’m trying to build a React Native iOS project in Xcode (Debug-iphonesimulator) but I keep getting “ScanDependencies” failures before compilation even begins:
ScanDependencies /Users/<username>/...
10
votes
1
answer
228
views
Why does this C++ operator overloading code work in Clang but not GCC/MSVC with C++20?
I recently encountered an interesting C++ code example that compiles with Clang (-std=c++20) but fails with GCC and MSVC. The code involves operator overloading and friend function declarations.
Code ...
4
votes
1
answer
144
views
Why are there symbols in my object file with `[abi:de180100]` appended?
I am compiling an application on macOS 15.4 with Xcode 16.1. Upon examining the object files the compiler produces, some of the symbols have [abi:de180100] appended to them. This suffix is not in the ...
5
votes
1
answer
196
views
Why does std::is_sorted() change between calls with clang
I have some code which is showing odd behavior when std::is_sorted() is called twice in a row; the result changes! The fist call returns false and the second call returns true. This happens with the ...
13
votes
0
answers
378
views
Why is this C++ code with fold expanded constraints rejected by Clang trunk?
#include <type_traits>
template <class T>
concept floating_point = std::is_floating_point_v<T>;
template <class T>
concept integral = std::is_integral_v<T>;
template &...
2
votes
0
answers
348
views
How do I avoid both modernize-deprecated-headers and misc-include-cleaner warnings?
I'm trying to remove all clang-tidy warnings in my C++ project. But I get alternating modernize-deprecated-headers and misc-include-cleaner warnings.
For example:
I use open_memstream in a file, so I ...
0
votes
1
answer
125
views
clang++ on Mac failing to locate the <iostream> header
I am trying to build a simple C++ program which includes the standard library header <iostream>, on a Mac.
When I compile my program in VS Code, I get the error message:
include errors detected. ...
4
votes
1
answer
187
views
Why doesn't GCC allow a constexpr std::string while Clang does?
I'm using GCC 14 and Clang 21. Why is the next C++23 code refused by GCC but Clang compiles without problems ? Both seems to support this functionality of C++20 and I'm using C++23. I think I've read ...
-2
votes
1
answer
72
views
clang c++ friend user defined literal declare failed [duplicate]
namespace ns {
class MyClass {
private:
int value;
MyClass(int val) : value(val) {}
friend MyClass operator"" _myudl(unsigned long long int val); // Friend UDL declaration
...
0
votes
0
answers
30
views
clang++ option to turn off literal operators
I've been doing some tests to try to use LLVM to build a big 20 year old project developed with GCC.
Among the vast number of issues one of the problems is with old Qt headers. We're building with -...
0
votes
0
answers
30
views
How to setup a conda environment on a Mac laptop to compile and run a hybrid C++/Python code with MPI support
I am trying to compile a CFD code on a Mac. The code is parallelized using MPI, and is written with a combination of C++ and Fortran. In addition, it runs a Python interpreter to handle IO tasks via ...
3
votes
0
answers
62
views
constexpr if with function parameter error with clang, gcc is ok
Here is the test code:
#include <type_traits>
enum class ShaderType:unsigned{
Vertex = 0,
Fragment = 1,
};
template<ShaderType type> struct ShaderTypeHolder{
static constexpr ...
0
votes
0
answers
137
views
Specify Include directory path with llvm build
Trying to set the include directory path for llvm build
Hi,
I am trying to build llvm with snmalloc allocator and as per the cmake options and instructions, I have set LLVM_INTEGRATED_CRT_ALLOC flag ...
1
vote
0
answers
16
views
How do I update my c++ version on a Mac M2 [duplicate]
I have been dealing with a lot of errors in my C++ code and then just realized I am running c++ 98. I am writing this for some help with updating it to c++20 or 17. From everything I have read, I have ...
14
votes
1
answer
414
views
Counting the number of present values in array of optionals with std::ranges
My colleague ports a C++ program with ranges on macOS, and observes an unexpected compilation error.
After maximum simplification, the example program looks like this:
#include <optional>
#...
0
votes
0
answers
138
views
Attempting build LLVM for iOS-simulator platform instead of macOS
I’m currently testing an interesting ARM64-to-x86_64 emulator implemented within the Xcode iOS Simulator. The goal is to enable Intel Macs to run ARM64 iOS binaries.
Part of the emulator’s code relies ...
3
votes
2
answers
215
views
How can multiple definitions in static libraries be detected/prevented?
It is known that some linkers do not report multiple definition errors when there are multiple definitions in static libraries. See for example here: Multiple definition within static library or here: ...
0
votes
0
answers
58
views
Understanding `omp_orig` in a custom OpenMP reduction
I've encountered a bug when using Clang[1] with libomp[2] whereby using omp_priv = omp_orig in the initializer of a custom OpenMP reduction silently gives erroneous output. For example:
/* file.cpp */
...
1
vote
2
answers
90
views
Why can't the result of boost::beast::http::async_write with token as_tuple(deferred) be converted to awaitable<tuple<error_code, size_t>>?
Clang tells me there is no viable conversion from the return value of boost::beast::http::async_write with completion token boost::asio::as_tuple(boost::asio::deferred) to awaitable<tuple<boost::...
1
vote
1
answer
324
views
Link the OpenMP library statically in C/C++
I have a simple C++ program that does nothing:
int main() { return 0; }
I am trying to build this program completely statically using the following command:
g++ -o c c.cc -static
Everything works ...
0
votes
0
answers
31
views
Clang searching for header in wrong place
I've tried to run my project, but it's complaining about not being able to find a header.
The reason it can't find it is because instead of searching my ./include directory, it's loading a framework ...
4
votes
1
answer
129
views
Is it compile bug? Accessing inactive member of union in constexpr function causes compile error in compile time evaluation
While I was playing with constexpr function, I faced the following issue.
Accessing inactive member of union is undefined behaviour I know. But there is one exception for this rule.
According to C++23 ...
0
votes
0
answers
79
views
Why is clang not consistent on noexcept(++it) and noexcept(*it) for containers?
I'm not sure if it is specified in the standard that advance/dereference of standard container iterator are noexcept. GCC and MSVC consistently make them noexcept for all standard containers. But ...
1
vote
0
answers
119
views
Refactor return type using clang transformer
Assume the following function:
const std::vector<std::unique_ptr<T>>& Foo::bar();
I'd like to refactor it to:
const std::vector<T>& Foo::bar();
And then, I'd like to ...
2
votes
0
answers
195
views
CMake Error: CMAKE_CXX_COMPILER not set when building Flutter app on Ubuntu
Was working on a namer_app example based on the video below. I created a new project to check as the dart sdk wasn't being referenced in the initial app:
import 'package:integration_test/...
2
votes
2
answers
198
views
AppleClang 15: no member named 'fetch_add' in 'std::atomic<float>'
I have a C++20 program that can be successfully built in Ubuntu 20 with GCC 10 or in Visual Studio 2019. And now I need to compile it for macOS 13.7.2 x64 (currently available on GitHub-hosted runner),...
0
votes
0
answers
63
views
Static linking in clang++ doesn't staticly link
I am new to c++ and created first program, it compiles and works on my machine but when i sent it to a friend they got 2 errors, basically:
libgcc_s_seh-1.dll not found
libwinpthread-1.dll not found
...
0
votes
1
answer
40
views
How does LLVM distinguish between clang and clang++ commands?
I'm exploring the LLVM/Clang source code and interested in understanding how LLVM distinguishes between clang and clang++ commands, knowing that clang++ is often considered an alias of clang. Which ...
-5
votes
1
answer
358
views
Unknown type name '__time64_t'
Trying compile my project with gcc is success. When trying to do so with any clang-based compiler the following error occur:
[build] /usr/bin/clang++ -I/mnt/40ab93ed-5db8-4e22-a055-9775c3e5b937/ISC-...
1
vote
2
answers
159
views
std::vector: why out_of_range error doesn't happen?
Mac M1.
I learn C++ by Bjarne Stroustrup's book. He show the similar example in his "Programming. Principles and Practice Using C++" book (chapter 5.6.2). Also he writes this exception (...
3
votes
1
answer
612
views
Why this code gives me compiler error: "Static assertion failed due to...the hash does not meet the Hash requirement"
Code pasted below:
auto myComp = []( std::array<const string, 3> &a, std::array<const string, 3> &b )
{
if ( a[0] == b[0] && a[1] == b[1] && a[2] == b[2] ) {
...