-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Labels
Description
Instantiating template with floating point NTTP results in crash.
Reproduction:
Code:
template<double NTTP>
struct MyTemplate {};
int main (int argc, const char** argv) {
auto instance = MyTemplate<3.14>{};
return 0;
}
Command to run:
infer capture -- clang++ -std=c++20 -o ./main.cpp.o -c ./main.cpp
Console Output:
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /usr/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18 @/home/huben/Projects/static-proto-c/build/unix-make-clang/infer-out/tmp/clang_command_.tmp.3c057f.txt
1. <eof> parser at end of file
#0 0x000055bc3dbe4127 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18+0x2308127)
#1 0x000055bc3dbe1cce llvm::sys::RunSignalHandlers() (/usr/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18+0x2305cce)
#2 0x000055bc3dbe490a (/usr/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18+0x230890a)
#3 0x00007ff3f9e3e540 (/usr/lib/libc.so.6+0x3e540)
#4 0x00007ff3fa1955b0 llvm::detail::PunnedPointer<llvm::PointerUnion<clang::Type const*, clang::ExtQuals const*>>::asInt() const /home/runner/work/infer/infer/facebook-clang-plugins/clang/install/include/llvm/ADT/PointerIntPair.h:41:5
#5 0x00007ff3fa1955b0 llvm::detail::PunnedPointer<llvm::PointerUnion<clang::Type const*, clang::ExtQuals const*>>::operator long() const /home/runner/work/infer/infer/facebook-clang-plugins/clang/install/include/llvm/ADT/PointerIntPair.h:45:48
#6 0x00007ff3fa1955b0 llvm::PointerIntPair<llvm::PointerUnion<clang::Type const*, clang::ExtQuals const*>, 3u, unsigned int, llvm::PointerLikeTypeTraits<llvm::PointerUnion<clang::Type const*, clang::ExtQuals const*>>, llvm::PointerIntPairInfo<llvm::PointerUnion<clang::Type const*, clang::ExtQuals const*>, 3u, llvm::PointerLikeTypeTraits<llvm::PointerUnion<clang::Type const*, clang::ExtQuals const*>>>>::getPointer() const /home/runner/work/infer/infer/facebook-clang-plugins/clang/install/include/llvm/ADT/PointerIntPair.h:94:58
#7 0x00007ff3fa1955b0 clang::QualType::hasLocalNonFastQualifiers() const /home/runner/work/infer/infer/facebook-clang-plugins/clang/install/include/clang/AST/Type.h:875:18
#8 0x00007ff3fa1955b0 clang::QualType::getLocalQualifiers() const /home/runner/work/infer/infer/facebook-clang-plugins/clang/install/include/clang/AST/Type.h:6866:7
#9 0x00007ff3fa1955b0 clang::QualType::getQualifiers() const /home/runner/work/infer/infer/facebook-clang-plugins/clang/install/include/clang/AST/Type.h:6873:52
#10 0x00007ff3fa1955b0 clang::QualType::getAddressSpace() const /home/runner/work/infer/infer/facebook-clang-plugins/clang/install/include/clang/AST/Type.h:6958:10
#11 0x00007ff3fa1955b0 clang::VarDecl::hasLocalStorage() const /home/runner/work/infer/infer/facebook-clang-plugins/clang/install/include/clang/AST/Decl.h:1174:21
#12 0x00007ff3fa1b49cc clang::VarDecl::hasGlobalStorage() const /home/runner/work/infer/infer/facebook-clang-plugins/clang/install/include/clang/AST/Decl.h:1210:43
#13 0x00007ff3fa1b49cc ASTLib::ASTExporter<ATDWriter::BiniouWriter<llvm::raw_ostream>>::dumpVarDeclInfo(clang::VarDecl const*) /home/runner/work/infer/infer/facebook-clang-plugins/libtooling/./ASTExporter.h:1709:22
Uncaught Internal Error: (Bi_inbuf.End_of_input)
Error backtrace:
Raised at Bi_inbuf.read_char in file "src/bi_inbuf.ml", line 49, characters 6-24
Called from Bi_io.read_tag in file "src/bi_io.ml" (inlined), line 508, characters 12-35
Called from ATDGenerated__Clang_ast_b.read_decl in file "src/atd/clang_ast_b.ml", line 46192, characters 7-24
Called from Atdgen_runtime__Util.Biniou.from_channel in file "atdgen-runtime/src/util.ml" (inlined), line 30, characters 4-11
Called from ClangFrontend__Capture.validate_decl_from_channel in file "src/clang/Capture.ml", line 25, characters 2-113
Re-raised at IStdlib__IExn.reraise_if in file "src/istd/IExn.ml" (inlined), line 18, characters 15-63
Called from ClangFrontend__Capture.run_and_validate_clang_frontend in file "src/clang/Capture.ml", line 109, characters 4-60
Called from IBase__Utils.with_process_in.f in file "src/base/Utils.ml" (inlined), line 291, characters 13-22
Called from IBase__Exception.try_finally in file "src/base/Exception.ml" (inlined), line 29, characters 8-12
Called from IBase__Utils.do_finally_swallow_timeout in file "src/base/Utils.ml", line 220, characters 12-45
Re-raised at IStdlib__IExn.reraise_after in file "src/istd/IExn.ml" (inlined), line 13, characters 2-50
Called from IBase__Exception.try_finally in file "src/base/Exception.ml" (inlined), line 42, characters 6-279
Called from IBase__Utils.do_finally_swallow_timeout in file "src/base/Utils.ml", line 220, characters 12-45
Called from ClangFrontend__Capture.run_clang in file "src/clang/Capture.ml", line 120, characters 8-78
Called from ClangFrontend__ClangWrapper.exe in file "src/clang/ClangWrapper.ml" (inlined), line 177, characters 15-45
Called from Stdlib__List.iter in file "list.ml" (inlined), line 110, characters 12-15
Called from Stdlib__List.iter in file "list.ml" (inlined), line 108, characters 13-64
Called from Base__List0.iter in file "src/list0.ml" (inlined), line 25, characters 16-35
Called from ClangFrontend__ClangWrapper.exe in file "src/clang/ClangWrapper.ml", line 177, characters 2-54
Called from Integration__Driver.capture in file "src/integration/Driver.ml", line 181, characters 10-44
Called from IBase__Utils.timeit in file "src/base/Utils.ml", line 437, characters 16-20
Called from IBase__ScubaLogging.execute_with_time_logging in file "src/base/ScubaLogging.ml", line 109, characters 26-41
Called from Backend__GCStats.log_f in file "src/backend/GCStats.ml" (inlined), line 93, characters 10-14
Called from Integration__Driver.capture in file "src/integration/Driver.ml", line 259, characters 2-362
Called from Dune__exe__Infer.run_ in file "src/infer.ml" (inlined), line 21, characters 2-36
Called from IBase__Utils.timeit in file "src/base/Utils.ml" (inlined), line 437, characters 16-20
Called from IBase__ScubaLogging.execute_with_time_logging in file "src/base/ScubaLogging.ml" (inlined), line 109, characters 26-41
Called from Dune__exe__Infer.run in file "src/infer.ml", line 28, characters 2-75
Run the command again with `--keep-going` to try and ignore this error.
I didn't dig deeper but its expected for Clang 18 to support floating point NTTPs.
(see: Paragraph addressing this change in the changelogs for Clang 18)
A workaround I use:
template <typename T>
struct Wrapped {
consteval explicit Wrapped (T value) : value(value) {}
T value;
};
using LongDouble = Wrapped<long double>;
using Double = Wrapped<double>;
using Float = Wrapped<float>;