0

I was compiling a code using LLVM and it failed compiling:

In file included from main.cpp:8:
In file included from /usr/lib/llvm-12/include/llvm/IR/LLVMContext.h:19:
In file included from /usr/lib/llvm-12/include/llvm/Support/CBindingWrapping.h:17:
/usr/lib/llvm-12/include/llvm/Support/Casting.h:309:7: error: cannot use 'throw' with exceptions disabled
      throw runtime_error("Address sanitizer is not turned on.");
      ^

I realized my llvm-config is disabling the exceptions for me.

llvm-config-12 --cxxflags --ldflags --system-libs --libs core

Returns

-I/usr/lib/llvm-12/include -std=c++14   -fno-exceptions -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-L/usr/lib/llvm-12/lib 
-lLLVM-12

In the past, I was not observing -fno-exceptions at all. A typical example should look like this.

Where does this exception prevention come from?

ar2015
  • 5,558
  • 8
  • 53
  • 110
  • From the [coding standards](https://llvm.org/docs/CodingStandards.html#do-not-use-rtti-or-exceptions). – arnt Jan 19 '22 at 10:36
  • @arnt, this exception and the others are inside llvm library code. I cannot remove them. – ar2015 Jan 19 '22 at 12:21
  • I suppose I was too quick; I thought you just wanted to know where the prevention comes from. – arnt Jan 19 '22 at 14:55

0 Answers0