cling
cling copied to clipboard
Structured binding doesn't work correctly.
$cling -std=c++2a
ERROR in cling::CIFactory::createCI(): cannot extract standard library include paths!
Invoking:
g++-5 -O3 -DNDEBUG -xc++ -E -v /dev/null 2>&1 | sed -n -e '/^.include/,${' -e '/^ \/.*++/p' -e '}'
Results was:
With exit code 0
Warning in cling::IncrementalParser::CheckABICompatibility():
Possible C++ standard library mismatch, compiled with __GLIBCXX__ '20171010'
Extraction of runtime standard library version was: '20200304'
****************** CLING ******************
* Type C++ code and press enter to run it *
* Type .q to exit *
*******************************************
[cling]$ #include <utility>
[cling]$ auto p = std::make_pair(2, "cpp")
(std::pair<int, const char *> &) { 2, "cpp" }
[cling]$ auto [a, b] = p
(std::pair<int, const char *> &) { 2, "cpp" }
[cling]$ a
input_line_7:2:2: error: use of undeclared identifier 'a'
a
^
[cling]$ #include <iostream>
[cling]$ std::cout << a
input_line_9:2:15: error: use of undeclared identifier 'a'
std::cout << a
^
[cling]$
Not surprising given that cling is stuck to clang 5 and that full support to structured binding came with clang 8. See also: https://github.com/root-project/cling/issues/276
Not surprising given that cling is stuck to clang 5 and that full support to structured binding came with clang 8. See also: #276
@dpellegr Thanks, I'll keep that in mind
This is a known limitation, we have a bug report open for it. It needs a bit more work than the (ongoing) llvm upgrade.
Current master leads to an assert:
root.exe: /opt/root_src/interpreter/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:3350: void clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl): Assertion `VD->isFileVarDecl() && "Cannot emit local var decl as global."' failed.
Dupe of https://github.com/root-project/cling/issues/193