Skip to content

Parsing of colors should not be locale dependent #46

Closed

Description

@simonschmeisser

rgba.push_back(std::stof(pieces[i]));

uses std::stof which is locale dependent and will truncate floats to ints if the decimal seperator does not match

this is the same issue as addressed in #45 but not included there as neither I nor anybody else looked closely enough ...

Activity

  1. gavanderhoorn commented on Oct 24, 2018

    @gavanderhoorn

    Would it be an idea to do an audit of the relevant packages for use of std::stof and similar methods and replace them where appropriate?

    I believe you've (@simonschmeisser) have proposed a similar change (moving away from locale-affected methods) for MoveIt. Seeing as this could be a cross-package issue: perhaps refactor this all out into a separate package and use that everywhere?

  2. simonschmeisser commented on Oct 24, 2018

    @simonschmeisser
    ContributorAuthor

    The change in MoveIt! is because boost::lexical_cast is inconsistent in itself (ie boost::lexical_cast<double>(boost::lexical_cast<std::string>(0.1)) will throw an exception)

    but yes, it's going to be a recurrent theme as more packages discover the nice (and totally inconsistent) features in C++ 11 and want to move away from boost::lexical_cast (which is not locale dependent ...)

    also note that the word "locale" does not appear a single time in boost::lexical_cast documentation so they might switch to using something broken in future releases ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions