[cfe-dev] g++ 4.2.8 vs libc++ - bug?

Nathan Froyd via cfe-dev cfe-dev at lists.llvm.org
Thu May 26 12:15:27 PDT 2016


This is due to differences in how libstdc++ and libc++ view reading
floating-point numbers from an input stream.  You can read a long,
slightly Firefox-specific explanation here:

https://hg.mozilla.org/mozilla-central/raw-rev/edd76ca3717f

-Nathan

On Thu, May 26, 2016 at 3:08 PM, Marco Wisse via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> Hi,
>
> I hope I found the right place for this question. I was trying something
> very basic, i.e. to read a double followed by a character, from cin, and
> noticed that there is a difference between the way this works using g++
> 4.2.8 on linux and the way it does (not work) using libc++ on a mac with the
> latest version of xcode.
>
> The entire code has only a few lines:
>
> ------------------------------------------------
> #include<iostream>
> using namespace std;
>
> int main() {
>     char c;
>     float d;
>     while(cin >> d >> c) cout << d << c <<  endl;
> }
> ------------------------------------------------
>
> When I compile this on linux using g++ 4.2.8, typing "2a", for example,
> produces "2a", and so on, as required.
>
> However, compiling this on the mac with Apple LLVM version 7.0.0
> (clang-700.0.72), using
> "clang++ -stdlib=libc++ --std=c++11 test.cpp", "2a", "2b", and quite a few
> more, fail.
>
> It seems strange to me that such a basic operation can produce different
> results. Do you have any thoughts?
>
> Kind regards,
> Marco
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>



More information about the cfe-dev mailing list