clang Questions

1

Solved

This code works in GCC and Clang, bug not on MSVC: #include <concepts> #include <utility> struct S {}; const S&& f(); S g(); static_assert(std::same_as<decltype(false ? f(...
Sinistrodextral asked 19/4, 2024 at 14:13

2

I'm trying to compile a simple app to test a few libraries I might be using in the future. Because of some problems I had with msvc I tried Clang, which made a strange error I got disappear. The p...
Reeder asked 25/7, 2019 at 20:12

13

Solved

I have a number of projects built using CMake and I'd like to be able to easily switch between using GCC or Clang/LLVM to compile them. I believe (please correct me if I'm mistaken!) that to use Cl...
Unskilled asked 11/8, 2011 at 18:42

1

Motivated by this question1, I created the following code: struct X { X(int) {} }; struct Y { operator X() { return X{1}; } operator int() { return 1; } }; int main() { X x(Y{}); } Live d...
Fanchan asked 23/8, 2018 at 7:43

6

Solved

I'm trying to get a simple 'Hello World' program to build on Windows 10, preferably using CMake and clang. I can successfully compile, link and run the same project if I use the g++ compiler from M...
Durarte asked 17/11, 2019 at 12:41

2

In standard C, is the expression i = (i = 1) + 1; well defined? What's the difference between it and i = ++i + 1; from the perspective of sequence points? Someone told me there is a sequence point ...
Kinson asked 7/4, 2024 at 3:37

10

Solved

The question is quite clear I think. I'm trying to write a compiler detection header to be able to include in the application information on which compiler was used and which version. This is part...
Middleaged asked 24/10, 2009 at 12:23

1

Suppose I'm using a library that has a declaration like this in its header: #if __cplusplus >= 201703L // C++17 or newer #define _NOTHROW noexcept(true) #define _THROWS(x) noexcept(false) #els...
Centrifuge asked 2/4, 2024 at 14:35

1

Solved

The code that fails for clang (while gcc seems okey with it) int arr[] { 111, 222, 333}; ranges::subrange( ranges::begin(arr),ranges::end(arr) ); It looks like clang claim gcc's subrange do not...
Feldman asked 11/10, 2020 at 5:17

1

According to the thread-sanitizer docs: ThreadSanitizer uses more real memory than a native run. At the default settings the memory overhead is 5x plus 1Mb per each thread. Settings with 3x (les...
Holey asked 8/1, 2019 at 9:44

2

Solved

Is there a way to get compilers to prefer libraries from LIBRARY_PATH instead of system paths. I am particularly looking for Clang. I partially solved the problem for GCC while writing this questio...
Libbi asked 12/11, 2017 at 11:32

3

Solved

This is the test code. #include <string> int main(int argc, char const *argv[]) { std::string a = "hello"; std::string b = "world"; return 0; } I compile it by the command: clang++ te...
Hypotenuse asked 1/9, 2016 at 3:3

0

I'm performing some experimentation on C++20 having in mind their potential usage in embedded application. However I noticed that both GCC and Clang generates frames that are bigger than the ones t...
Meingoldas asked 28/2, 2024 at 0:54

2

I'm trying to wrap a Python lib around a C++ lib and distutils is failing for me on OS X. Here are the relevant lines from my setup.py: if sys.platform.startswith("darwin"): extra_compile_args_se...
Ancestral asked 21/9, 2018 at 10:41

2

I have a C++ program that I'm building with Clang 3.9's profile-guided optimization feature. Here's what's supposed to happen: I build the program with instrumentation enabled. I run that program...
Unceasing asked 8/2, 2017 at 22:39

3

I have some hand-vectorized C++ code that I'm trying to make a distribute-able binary for via function multiversioning. Since the code uses SIMD intrinsics for different instruction sets (SSE2, AVX...
Hypercorrection asked 25/10, 2020 at 19:7

1

I always compile my programs with gcc and during development always with: gcc -g -Wall -Wextra -std=c2x -fsanitize=address,undefined Today I noticed that the address sanitizer randomly detects SEG...
Carburetor asked 28/1, 2024 at 12:56

1

Solved

The Problem Recently on Linux Kernels 6.6.6 and higher it was discovered that thread sanitizer will always lead to this error: FATAL: ThreadSanitizer: unexpected memory mapping 0x5c9bd4d2b000-0x5c9...
Carrasco asked 20/1, 2024 at 11:6

2

Solved

It seems that I cannot get information on all the preprocessor macros of a clang program from gdb. Consider this simple code: #include <stdio.h> #define MACRO_B 2 int main() { printf(&quot...
Cult asked 18/1, 2024 at 15:30

1

Solved

I hope to match all for-loop with vector declaring in it's body (might extend to while-loop and do-while-loop later): #include <vector> int main() { for (int i = 0; i < 10; i++) { std::...
Cloy asked 9/1, 2024 at 7:34

5

Solved

Consider the following piece of code: struct foo { static constexpr const void* ptr = reinterpret_cast<const void*>(0x1); }; auto main() -> int { return 0; } The above example compil...
Bon asked 24/6, 2014 at 23:48

5

Solved

Consider the following piece of code: struct foo { static constexpr const void* ptr = reinterpret_cast<const void*>(0x1); }; auto main() -> int { return 0; } The above example compil...
Perdition asked 24/6, 2014 at 23:48

18

Solved

Is there a way to call something like clang-format --style=Webkit for an entire cpp project folder, rather than running it separately for each file? I am using clang-format.py and vim to do this, ...
Fridlund asked 6/3, 2015 at 10:31

1

Solved

I have a project where I use -flto=thin for my main targets, but I don't want to apply LTO to my tests since it slows compilation down (full context: lld runs LTO even if -fno-lto is passed). As it...
Infundibulum asked 16/5, 2022 at 13:50

0

This is related to an issue described in this question -- a reproducible example can be found there, as well as a description of the environment (briefly: Apple Silicon with macOS Sonoma and clang ...
Demonology asked 25/12, 2023 at 15:37

© 2022 - 2025 — McMap. All rights reserved.