Discrepancy between istream's operator>> (double& val) between libc++ and libstdc++

你离开我真会死。 提交于 2019-11-28 12:11:40

It looks like that libstdc++ is right and libc++ is wrong, according to the 22.4.2.1.2 of the (2011) standard.

At stage 2,

If it [the character - n.m.] is not discarded, then a check is made to determine if c is allowed as the next character of an input field of the conversion specifier returned by Stage 1 ["%g" in this case - n.m.] . If so, it is accumulated.

Since %g conversion specifier does not admit d or X characters, the character is not accumulated. It is not discarded either (only group separator characters can be discarded). Therefore Stage 2 must end at this point.

Then at stage 3 accumulated characters are converted.

It looks like libc++ erroneously accumulates d and X at stage 2, then attempts to convert them, and this fails.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!