Questions tagged [clang]

For questions about the clang LLVM compiler front end. For general questions about C, use the C tag.

Filter by
Sorted by
Tagged with
0 votes
0 answers
9 views

Extact variable arguments from the current Function in LLVM Pass

In LLVM11 Function Pass, I am trying to insert a self-call to the current function with variable arguments based on the condition. //Original Function #include <stdio.h> double test_function(...
Sandesh's user avatar
  • 23
0 votes
0 answers
52 views

Mysteriously not encountering compiler error [duplicate]

https://godbolt.org/z/aexGW1x48 In the above code, in the following line std::int64_t tempVal = std::ceil(tempVal); tempVal is referenced in std::ceil before it is declared or instantiated. Yet, the ...
Hedgehog's user avatar
1 vote
0 answers
34 views

Function pointer is 0

So, I am trying to develop my own OS. Its going preety well but i am encountering an issue. While setting up the IDT, i wanted to get address of the ISR0 function using &isr0 like this: //The ...
Stigl's user avatar
  • 39
1 vote
0 answers
36 views

Using clang++ with C++23 and gcc candiate 12 cannot find expected header

I'm wanting to use C++23's <expected>, but clang is unable to find it on my system unless I add -stdlib=libc++, which causes other errors with various shared libs compiled against libstdc++. I ...
nathansizemore's user avatar
5 votes
1 answer
107 views

Fastest way to perform an atomic read in this *very* specific situation?

Background It turns out that all(?) compilers treat std::atomic::load(std::memory_order_relaxed) as a volatile load (via __iso_volatile_load64, etc.). They don't optimize or reorder it at all. Even ...
user541686's user avatar
  • 206k
0 votes
0 answers
14 views

g++ mistake the meaning of rdi and rsi register

First of all, i make use of clang++ to generate one library named libbase-core.so. Then i wrote one main.cc. #include <string> #include "base/single_thread_task_runner.h" #include &...
josephWu's user avatar
0 votes
0 answers
84 views

Is there a timeline for Clang to be 100% compliant with C++20? [closed]

Class Template Argument Deduction for alias templates is still not supported in Clang 17, per https://clang.llvm.org/cxx_status.html. Is there a current published timeline for 100% compliance for c++...
MarkB's user avatar
  • 708
0 votes
1 answer
47 views

Confusing clang fibonacci disassembly [closed]

I cannot comprehend How this: int fib_iter(int num) { int a = 1; int b = 1; int c = 0; for (int i = 0; i < num; i++) { c = a; b += a; a = c; } ...
xodix's user avatar
  • 1
0 votes
0 answers
18 views

Clang ld failure in yocto build

While generating SDK for hardknott-based distro the following error occured from clang_git.bb:do_compile(): qemux86-64/tmp-glibc/hosttools/ld: cannot find -ltinfo qemux86-64/tmp-glibc/hosttools/ld: ...
Wojciech Siudy's user avatar
2 votes
1 answer
75 views

sort out IP addrs from file in C program

So, I have to create a .c file which sorts out IP addresses in ascending order and gives a count to all ip adresses. Considering there is ip.txt file present while has content like below (IP Address ...
Shivansh's user avatar
0 votes
2 answers
66 views

What compiler options does `-O2` enable in clang? [duplicate]

We've found that -O2 breaks a program, and we would like to find out which optimization option actually causes the problem, so we can produce a bug report. Is there an equivalent list of options that -...
KJ7LNW's user avatar
  • 1,535
0 votes
0 answers
19 views

LLVM IR: crashes at very end

I have the following code: @.str.2 = constant [4 x i8] c"\25d\0a\00" define i32 @main() { %.0 = call i32 () @"main::main"() call void (ptr, ...) @printf(ptr @.str.2, i32 %....
1Dr490n's user avatar
  • 23
0 votes
0 answers
15 views

Compile tvm with bazel can't involve llvm

I tried to compile TVM with bazel, but block in src/target/llvm. Here is my TVM bazel BUILD file cc_library( name = "llvm_compiler", srcs = glob([ "src/target/llvm/*.cc", ]), ...
Tim Cheng's user avatar
0 votes
1 answer
122 views

How to tell GCC/Clang optimizer to generate specific sequence of operations

I have a loop that needs to execute sequences of operations in a specific order. What I am doing here is manually unrolling the loop a number of times: loop { delta = get_delta(); sum1 += ...
Milhouse Vanhouten's user avatar
-1 votes
0 answers
36 views

Lack of LLVM support [closed]

LLVM is such a powerful tool, it is very well established and has a large community. As an undergraduate student I had project and needed to use the LLVM API. Words cannot describe how traumatised I ...
Jonas's user avatar
  • 1
-1 votes
0 answers
85 views

Why does GCC inline memset but Clang does not?

I have three functions below (create1(), create2(), create3()). Each does the same thing, initializing an object to contain zeros. The first two do it explicitly, the last function uses C++ default ...
user5406764's user avatar
  • 1,689
0 votes
0 answers
25 views

iOS Swift Stuck When Using A Static pthread_rwlock in Release Build but Debug Build Works Fine

I'm using Xcode15 and targeting iOS 17. The freeze happens on the Manager.setValue(key:value:) call within the init method of the StaticRwlockApp struct. This issue does not occur when I run the app ...
yfkyqdk's user avatar
0 votes
2 answers
87 views

With C++11, how can I generate a warning message in a manner that works in gcc, clang, and MSVC?

When compiling C++11 using clang or gcc, I can generate a warning message at compilation time using: #warning My message here This doesn't work on Windows when I use MSVC, though. How can I ...
Bri Bri's user avatar
  • 2,087
-1 votes
0 answers
49 views

Is the assignment to a returned pointer with side effects on both sides unspecified behaviour? [duplicate]

The following code has different behavior when comparing the result between GCC and Clang. I originally thought it was a expression ordering issue but instead it looks like the behavior of the ...
broomhead123's user avatar
0 votes
1 answer
23 views

Rcpp Rf_warningcall compiler warnings

In the C++ code of the R/terra package I using the below to handle warnings: template <typename... Args> inline void warningNoCall(const char* fmt, Args&&... args ) { Rf_warningcall(...
Robert Hijmans's user avatar
0 votes
1 answer
28 views

clang template matching cannot match pointer to method inherited from base class

The following code does not compile with Clang (but compiles fine with MSVC): class Base { public: int bla() { return 1; } }; class Derived : public Base { }; template <typename T> void ...
Andor Pathó's user avatar
0 votes
1 answer
25 views

Error during build for Android NDK on Windows with clang

Currently I am trying to deal with building a C shared library for Android. I have installed Android Studio with NDK (Side by side), but have to build it all with another build tool (Qbs of an ...
DumbStudent2016's user avatar
-1 votes
1 answer
31 views

Is optimization to move block inside both the block of a if-else branch correct?

Warning(Pseudocode) Suppose we have a kernel : def kernel(array): a = get_global_id(0) if a > 1: array[0] = 10 barrier(LOCAL_MEM_FENCE) Is it wrong for the code to get optimized ...
Rohan Jha's user avatar
0 votes
0 answers
31 views

LLVM: Does PrologEpilog Insertion pass acts only on entry block

I'm trying to insert splitblock at start of a function in function pass?? Trying this results in losing stack optimization done through PrologEpilog pass on entry block. This seem to be because of ...
user22870953's user avatar
0 votes
1 answer
24 views

Compiling ns3 using clang results in undefined symbol linker error

I've downloaded ns-3.39, unpacked and compiled it using wget https://www.nsnam.org/releases/ns-allinone-3.39.tar.bz2 tar xfj ns-allinone-3.39.tar.bz2 cd ns-allinone-3.39/ns-3.39/ ./ns3 configure --...
kunterbunt's user avatar
0 votes
1 answer
20 views

How can I compile a program using Clang from standard input?

I have a program coming from standard input. I would like to compile it. Is this possible and if so, how can I do this?
Justine Krejcha's user avatar
0 votes
2 answers
227 views

An extremely simple program triggers an 'unhandled instruction' error when compiled with sanitizers

I have this trivial C code (it could be C++) $ cat .\main.c #include <stdio.h> int main() { printf("Hello"); return 0; } When I compile it with address sanitizer. clang -...
Rodrigo's user avatar
  • 55
1 vote
0 answers
20 views

What's the right way to use eBPF's "bpf_current_task_under_cgroup" and other helper functions on Android?

Wish you a nice day first. Recently I started to learn using eBPF on Android. Actually I am a beginner of Android APP development. Things are not bad at first, and I successfully built up a demo. But ...
Cube Lee's user avatar
0 votes
0 answers
79 views

Duplicate symbol in Clang (but not GCC) when overriding __cxa_throw

I'm trying to get a bit more information in __cxa_throw. Regardless of the wisdom of this, the following code works perfectly with gcc and from the limited information I can find about this, it should ...
Steve's user avatar
  • 11.8k
0 votes
0 answers
26 views

Running QEMU with support for RISC-V Vector Extensions

I am doing research for my thesis on a topic that requires running QEMU with support for the SVE format. My issue is that I cannot figure out how to find the matching versions of the various tools ...
Stelios Papamichail's user avatar
0 votes
0 answers
60 views

Problems with standard C++ libraries in YesCompleteMe

I decided to try Vim as an IDE for C++, I installed the YesCompleteMe plugin for autocompletion, but I encountered a problem, the plugin cannot find standard C++ libraries, for example "iostream&...
bin4ry's user avatar
  • 31
0 votes
1 answer
198 views

Compiling a minimal CPP program with "-fsanitize=address" causes immediate segfault [duplicate]

Compiling "example" (a very simple CPP program consisting of just a return in main) with address sanitization and running it results in immediate segfault. makefile CXX = clang++ SANI = ...
Justin Shin's user avatar
2 votes
0 answers
102 views

Clang-compiled program crashes with segfault when fsanitize=address is on [duplicate]

I created the minimal example C++ program and wanted to try out clang's address sanitizer: #include <iostream> int main() { std::cout << "Hello World!" << std::endl; ...
huzzm's user avatar
  • 557
0 votes
0 answers
28 views

Get error message from Python/clang.cindex C++ parser

The following Python code is supposed to parse C++ code: import clang.cindex index = clang.cindex.Index.create() translation_unit = index.parse(cpp_source_filename, args=['-std=c++20']) Problems ...
Joachim W's user avatar
  • 7,400
0 votes
0 answers
24 views

Understanding Compiler Version Impact on Building R and R Packages

I am currently performing local testing based on rhub images, which requires to install R packages (and other dependencies) from source. I’ve noticed that the compiler versions used in the rhub images ...
Mat D.'s user avatar
  • 483
0 votes
0 answers
26 views

How to get the AST parent of attribute CXCursor

How can I get the parent cursor that appears in clang_visitChildren callback? For instance, consider the following code to be parsed: __attribute__((visibility("default"))) void func(); If ...
liaohy's user avatar
  • 55
0 votes
1 answer
36 views

Compilers allow a weak symbol function with no implementation and no linker error

A static library declares a function with a weak symbol. Later an application (not providing the function implementation) statically links the library but no linker error is generated. This seems to ...
rare77's user avatar
  • 311
0 votes
1 answer
91 views

No linker error when static library calls weak function with no implementation [duplicate]

The overall problem I am trying to solve: I would like a library statically-linked to my application, to call a function within my application. However, when the library is compiled and installed, it ...
rare77's user avatar
  • 311
0 votes
3 answers
67 views

Arithmetic which gives the lowest 64 bits on overflow

In C unsigned integer arithmetic wraps around on overflow and signed arithmetic is undefined on overflow. I would like to have 64 bit integer arithmetic (+,-,*) so that on overflow the result is the ...
Simd's user avatar
  • 19.8k
0 votes
0 answers
26 views

How to compile clang llvm to amd gcn on linux ubuntu

I've been trying for about two days to compile clang-llvm for amd gcn and I'm stuck. My goal here is to be able to compile a hip program using the triple amdgcn-amd-amdhsa. I cloned the project (llvm ...
The Noderinator's user avatar
1 vote
0 answers
61 views

Macos C compilation error "ld: Undefined symbols: _main, referenced from: <initial-undefines>"

I am having a compilation error on mac when I try to compile my c program error ld: Undefined symbols: _main, referenced from: <initial-undefines>` #include <stdio.h> int main()...
Flames's user avatar
  • 11
0 votes
0 answers
16 views

How to link libc.a files to clang

When i try to compile a c program using clang frontend, i am getting a error saying: ld.lld: error: unable to find library -lc ld.lld: error: unable to find library -lm ld.lld: error: unable to find ...
Nehal Sangaonkar's user avatar
-1 votes
0 answers
18 views

how to measure clock cycles on M1 max using C lang?

how to measure clock cycles on M1 max using C lang? I want to bench my C code on M1 max CPU and compare with clock cycles on Intel, but I cannot find any codes for measuring clock cycles using C lang. ...
DAMPER's user avatar
  • 1
0 votes
0 answers
16 views

How to read .llvm_addrsig section from relocatable object file or an ELF?

I have got a vague idea about what .llvm_addrsig section is from this post and linker use this to prevent ICF.. https://discourse.llvm.org/t/problems-with-mach-o-address-significance-table-generation/...
Kishan Parmar's user avatar
1 vote
1 answer
45 views

How to make clang format not place comments?

Every time I create a namespace or start a namespace block, clang-format adds a comment at the namespace closing. I don't want this. How do I disable it? Example: } // namespace geometry My ...
Rodrigo's user avatar
  • 55
0 votes
0 answers
49 views

Clang 13, 14, and 15 compiling for release causing incorrect incrementing of variables

I'm writing a simple little wavefront object (.obj) file loading utility. Code and .obj file required to recreate this issue are found here on this github repository The first step I use is to count ...
Balluwun enjoyer's user avatar
1 vote
1 answer
37 views

What's the difference between Clang invoked by Bash and the ClangTool?

The original question I followed a tutorial and created a tool named ast_extract to analyze the source code of libpng: llvm::cl::OptionCategory ASTExtractCategory("ASTExtract tool options"); ...
Fanke Tong's user avatar
5 votes
1 answer
176 views

Should GCC/Clang optimize this redundant load via an array of restrict-qualified pointers?

I am looking into optimizations permitted for a compiler by adding the C99 restrict type qualifier to the type parameter of an array. For example, consider the function f below: int f(int* restrict a[...
Ties's user avatar
  • 51
0 votes
1 answer
69 views

Why clang and gcc output different results under `-std=c89` option?

I came across this quiz, so want to verify it myself: #include <stdio.h> void print_sum(a, b) { printf("%d\n", a + b); } int main(void) { print_sum(1.5, 8.5); return 0; } ...
Nan Xiao's user avatar
  • 16.9k
-1 votes
0 answers
73 views

How do I configure clang to use clang version of the standard library via CMake? [duplicate]

I am compiling a large C++ project with clang 16.0.4. I have a docker image that sets up a clean development environment. When I compile the code on that image everything goes smoothly. I think this ...
Elad Maimoni's user avatar
  • 3,841

1
2 3 4 5
205