Skip to content

Test failures when building with clang #939

Closed
@dsobek

Description

@dsobek

Describe the bug
When building with clang on master, tests are failing with c++ exception:
C++ exception with description "Value outside numeric limits" thrown in the test body.

Any.Cast appears to be the most minimal testcase that is failing. It comes down to casts from any integral type to a double type.

How to Reproduce

Please provide a specific description of how to reproduce the issue or source code that can be compiled and executed. Please attach a file/project that is easy to compile, don't copy and paste code snippets!

From project root:

CC=clang CXX=clang++ colcon build
./build/behaviortree_cpp/tests/behaviortree_cpp_test

Root cause

I've found that the root cause is in checkTruncation

In particular if To has a larger max value than From (say for example To is double and From is int), static_cast<From>(std::numeric_limits<To>::max()) does not always evaluate to the max value of From. In clang, with any optimization (I see behaviortree.cpp is built with -O3), this evaluates to 0. I am not sure if this is meant to be undefined behavior but it sure is acting like it.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions