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

C++11 narrowing conversions #1434

Merged
merged 2 commits into from Nov 4, 2012

Conversation

mgiuca-google
Copy link
Contributor

Just a couple of small fixes to allow Matplotlib to compile with -std=c++11. The problem is that C++11 does not allow implicit narrowing conversions (in this case, a cast from size_t, which is unsigned, to npy_intp, which is signed) in an initialiser list.

I was getting errors compiling these files with clang and -std=c++11:

lib/matplotlib/tri/_tri.cpp:280:25: error: non-constant-expression cannot be narrowed from type 'size_type' (aka 'unsigned long') to 'npy_intp' (aka 'long') in initializer list
lib/matplotlib/tri/_tri.cpp:574:29: error: non-constant-expression cannot be narrowed from type 'size_type' (aka 'unsigned long') to 'npy_intp' (aka 'long') in initializer list
src/_path.cpp:1356:33: error: non-constant-expression cannot be narrowed from type 'unsigned long' to 'npy_intp' (aka 'long') in initializer list

This patch fixes those errors. Note that GCC 4.6 with -std=c++0x does not catch this error, even though it violates the new specification. I don't know if GCC 4.7 has fixed this, but in any case, it is good to be future-proof.

@mdboom
Copy link
Member

mdboom commented Oct 31, 2012

Thanks for taking the trouble to track this down. These look reasonable.

@dmcdougall
Copy link
Member

+1

ianthomas23 added a commit that referenced this pull request Nov 4, 2012
@ianthomas23 ianthomas23 merged commit c63f671 into matplotlib:master Nov 4, 2012
@mgiuca-google
Copy link
Contributor Author

Thanks, Ian.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants