Raspberry Buster上CLANG中的代码或编译器错误

时间:2019-07-08 06:36:54

标签: c++ raspbian clang++

我有一些代码可以从文本文件中读取数据并将其转换为float。在都运行raspbian 10 Buster的新Raspberry PI(3B +和0)上,我使用clang ++(v 7.0.1)遇到奇怪的行为。代码

#include <iostream>
#include <string>

using std::cout;
using std::endl;

int main(void){

    std::string str="3.14";
    float fl = std::stof(str);

    cout << fl << endl;
    cout << fl << endl;
    cout << fl << endl;

    return 0;
}

clang++ -std=c++11编译会产生以下输出:

$ a.out 3.14 3.68935e+19 0

我的代码中是否存在基本错误,或者是clang的问题?

该问题仅出现在我的新PI上,并且仅使用clang ++(不适用于g ++)。当我将“ float”更改为两倍(“ stof”更改为“ stod”)时,行为符合预期(输出为“ 3.13”的三倍)

更新2019年7月18日似乎可以通过更新clang来解决

0 个答案:

没有答案