cling icon indicating copy to clipboard operation
cling copied to clipboard

Structured binding doesn't work correctly.

Open hi60year opened this issue 4 years ago • 3 comments

$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]$ 

hi60year avatar May 17 '20 00:05 hi60year

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

dpellegr avatar Jun 06 '20 11:06 dpellegr

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

hi60year avatar Jun 07 '20 00:06 hi60year

This is a known limitation, we have a bug report open for it. It needs a bit more work than the (ongoing) llvm upgrade.

Axel-Naumann avatar Jun 07 '20 10:06 Axel-Naumann

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.

ferdymercury avatar Apr 12 '24 15:04 ferdymercury

Dupe of https://github.com/root-project/cling/issues/193

ferdymercury avatar Apr 12 '24 16:04 ferdymercury