[英]Is this a g++ or CLion bug ( using Ctrl+D in CLion)?
On using the following code关于使用以下代码
#include <iostream>
#include <vector>
#include <string>
int main()
{
std::vector<std::string> vec;
std::string temp{};
while(std::cin >> temp) vec.push_back(temp);
std::cout << "\n[ " << vec[0];
for(int i {1}; i < vec.size(); i++) std::cout << ", " << vec[i];
std::cout << "]";
}
with the following inputs具有以下输入
kghukg kjhukg 6887 ^D
I get我得到
Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
I am using CLion on ubuntu and我在 ubuntu 上使用 CLion 并且
asmmo@asmmo:~$ g++ --version
g++ (Ubuntu 9.3.0-8ubuntu1) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I get that error with std=-s++1z
and c++2a
我收到std=-s++1z
和c++2a
Considering a comment, I updated the code to考虑到评论,我将代码更新为
#include <iostream>
#include <vector>
#include <string>
#include <thread>
using namespace std::chrono_literals;
int main()
{
std::vector<std::string> vec;
std::string temp{};
while(std::cin >> temp) vec.push_back(temp);
std::cout<<vec.size();
std::this_thread::sleep_for(10s);
std::cout << "\n[ " << vec[0];
for(int i {1}; i < vec.size(); i++) std::cout << ", " << vec[i];
std::cout << "]";
}
then used然后使用
kjjkj jkh 555 ^D
but it waited thwn didn't display anything but the error但它等待 thwn 除了错误没有显示任何东西
My psychic guess is that this is a problem with how CLion is submitting input to the program.我的心理猜测是,这是 CLion 如何向程序提交输入的问题。
https://youtrack.jetbrains.com/issue/CPP-5704 https://youtrack.jetbrains.com/issue/CPP-5704
I can disable keycaps for ⌘+D and Ctrl-D, and rely on the "Send EOF" action or the ⌘-D and Ctrl-D keypresses with Clion keycaps disabled, the result is the same: the program does not receive a EOF but receives some sort of kill signal.我可以禁用 ⌘+D 和 Ctrl-D 的键帽,并依靠“发送 EOF”操作或禁用 Clion 键帽的 ⌘-D 和 Ctrl-D 按键,结果是一样的:程序没有收到 EOF但收到某种终止信号。
Apparently some people find a way to circumvent this:显然有些人找到了一种方法来规避这一点:
https://xbuba.com/questions/45803954 https://xbuba.com/questions/45803954
Disabling the run.processes.with.pty in Registry (open via Find Action) usually helps.禁用注册表中的 run.processes.with.pty(通过 Find Action 打开)通常会有所帮助。
I never understood the hype with Jetbrains tools ...我从来不明白 Jetbrains 工具的炒作...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.