Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler workarounds #83

Closed
JohanMabille opened this issue Jan 24, 2017 · 0 comments
Closed

Compiler workarounds #83

JohanMabille opened this issue Jan 24, 2017 · 0 comments

Comments

@JohanMabille
Copy link
Member

JohanMabille commented Jan 24, 2017

This issue is meant for tracking the workarounds we have implemented around compiler bugs

MSVC 2015: bug with std::enable_if and invalid types

std::enable_if evaluates its second argument, even if the condition is false. This is the reason for the get_xfunction_type_t workaround which adds a level of indirection for the second type to always be a valid type (Original issue #80, fixed in PR #148).

MSVC 2015: math functions not fully qualified

fma class is ambiguous if not fully qualified. See #81.

GCC-4.9 and clang < 3.8: constexpr std::min and std::max

std::min and std::max are not constexpr in these compiler. In xio.hpp, we define a XTENSOR_MIN macro before its usage and undefine it right after.

clang < 3.8 matching initializer_list with static arrays.

Old versions of clang don't handle overload resolution with braced initializer lists correctly: braced initializer lists are not properly matched to static arrays. This prevent compile-time detection of the length of a braced initializer list.

A consequence is that we need to use stack-allocated shape types in these cases.

GCC-6: std::isnan and std::isinf.

We are not directly using std::isnan or std::isinf in xmath as a workaround to the following bug in GCC-6 for the following reason.

C++11 requires that the <cmath> header declares bool std::isnan(double) and bool std::isinf(double).
C99 requires that the <math.h> header declares int ::isnan(double) and int ::isinf(double).
These two definitions would clash when importing both headers and using namespace std.

As of version 6, gcc detects whether the obsolete functions are present in the C <math.h> header and uses them if they are, avoiding the clash. However, this means that the function might return int instead
of bool as C++11 requires, which is a bug.

@JohanMabille JohanMabille changed the title Windows fixes Windows workarounds Jan 24, 2017
@JohanMabille JohanMabille mentioned this issue Mar 3, 2017
@SylvainCorlay SylvainCorlay changed the title Windows workarounds Compiler workarounds Mar 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant