cling icon indicating copy to clipboard operation
cling copied to clipboard

cling goes into strange state after raising error about missing std::

Open nthiery opened this issue 8 years ago • 3 comments

The following snippet rightfully triggers an error in cling:

    #include <string>
    string s

However, cling goes into a weird state where it does not accept anymore:

    std::string s

I am using cling installed from QuantStack's conda repository:

/opt/miniconda3/bin/cling --version
0.4~dev

Full trace:

****************** CLING ******************
* Type C++ code and press enter to run it *
*             Type .q to exit             *
*******************************************
[cling]$ #include <string>
[cling]$ string s
input_line_4:2:2: error: unknown type name 'string'; did you mean 'std::string'?
 string s
 ^~~~~~
 std::string
/opt/miniconda3/gcc/include/c++/bits/stringfwd.h:74:33: note: 'std::string' declared here
  typedef basic_string<char>    string;   
                                ^

[cling]$ std::string s
input_line_5:2:14: error: no matching constructor for initialization of 'std::string' (aka 'basic_string<char>')
 std::string s
             ^
/opt/miniconda3/gcc/include/c++/bits/basic_string.h:549:9: note: candidate constructor template not viable: requires at least 2 arguments, but 0 were provided
        basic_string(_InputIterator __beg, _InputIterator __end,
        ^
/opt/miniconda3/gcc/include/c++/bits/basic_string.h:389:7: note: candidate constructor not viable: requires single argument '__a', but no arguments were provided
      basic_string(const _Alloc& __a) _GLIBCXX_NOEXCEPT
      ^
/opt/miniconda3/gcc/include/c++/bits/basic_string.h:397:7: note: candidate constructor not viable: requires single argument '__str', but no arguments were provided
      basic_string(const basic_string& __str)
      ^
/opt/miniconda3/gcc/include/c++/bits/basic_string.h:476:7: note: candidate constructor not viable: requires single argument '__str', but no arguments were provided
      basic_string(basic_string&& __str) noexcept
      ^
/opt/miniconda3/gcc/include/c++/bits/basic_string.h:454:7: note: candidate constructor not viable: requires at least argument '__s', but no arguments were provided
      basic_string(const _CharT* __s, const _Alloc& __a = _Alloc())
      ^
/opt/miniconda3/gcc/include/c++/bits/basic_string.h:503:7: note: candidate constructor not viable: requires at least argument '__l', but no arguments were provided
      basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc())
      ^
/opt/miniconda3/gcc/include/c++/bits/basic_string.h:507:7: note: candidate constructor not viable: requires 2 arguments, but 0 were provided
      basic_string(const basic_string& __str, const _Alloc& __a)
      ^
/opt/miniconda3/gcc/include/c++/bits/basic_string.h:511:7: note: candidate constructor not viable: requires 2 arguments, but 0 were provided
      basic_string(basic_string&& __str, const _Alloc& __a)
      ^
/opt/miniconda3/gcc/include/c++/bits/basic_string.h:410:7: note: candidate constructor not viable: requires at least 2 arguments, but 0 were provided
      basic_string(const basic_string& __str, size_type __pos,
      ^
/opt/miniconda3/gcc/include/c++/bits/basic_string.h:444:7: note: candidate constructor not viable: requires at least 2 arguments, but 0 were provided
      basic_string(const _CharT* __s, size_type __n,
      ^
/opt/miniconda3/gcc/include/c++/bits/basic_string.h:464:7: note: candidate constructor not viable: requires at least 2 arguments, but 0 were provided
      basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc())
      ^
/opt/miniconda3/gcc/include/c++/bits/basic_string.h:426:7: note: candidate constructor not viable: requires 4 arguments, but 0 were provided
      basic_string(const basic_string& __str, size_type __pos,
      ^

nthiery avatar Sep 04 '17 14:09 nthiery

I got the same error...

I have used cling 0.6~dev on Ubuntu.

permotion88 avatar Aug 24 '18 11:08 permotion88

Similar problem in my WSL Linux MSI 4.4.0-17134-Microsoft #523-Microsoft Mon Dec 31 17:49:00 PST 2018 x86_64 GNU/Linux

[cling]$ #include <iostream> [cling]$ using namespace std; [cling]$ cout << "srini hi"; In file included from input_line_3:1: In file included from /usr/include/c++/8/iostream:39: /usr/include/c++/8/ostream:559:8: error: no member named 'setstate' in 'std::basic_ostream' __out.setstate(ios_base::badbit); ~~~~~ ^ input_line_6:2:7: note: in instantiation of function template specialization 'std::operator<<<std::char_traits >' requested here cout << "srini hi"; ^

rsrini7 avatar Jan 14 '19 06:01 rsrini7

issue may be in cling::Interpreter::unload function. It unloads headers without ability to auto-load them again.

derofim avatar Aug 17 '19 13:08 derofim