This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 373 - Clang compilation fails with exceptions disabled
Summary: Clang compilation fails with exceptions disabled
Status: RESOLVED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.0
Hardware: All All
: Normal Unknown
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-09 04:19 UTC by Aaron Lindsay
Modified: 2019-12-04 11:15 UTC (History)
2 users (show)



Attachments

Description Aaron Lindsay 2011-11-09 04:19:32 UTC
Hi,

When compiling any program that includes Eigen with -fno-exceptions in Clang, compilation will fail with the following error:

In file included from Eigen/Core:252:
Eigen/src/Core/util/Memory.h:90:13: error: 
      array is too large (18446744073709551615 elements)
    new int[size_t(-1)];
            ^~~~~~~~~~

This has been tested with both Apple's clang included in the iOS SDK 5.0, and a Linux x86_64 clang version 2.9 (tags/RELEASE_29/final).

Perhaps abort() or something similar in this situation would work?

Thanks,
 - Aaron
Comment 1 Benoit Jacob 2011-11-09 04:32:57 UTC
hm. It's computing at compile time that the byte size exceeds the max value of a size_t. I wonder if this is allowed by the c++ spec.

Does any of the following compile:

new char[size_t(-1)];

or

new int[size_t(-1)/sizeof(int)];

Either would work as that would still be guaranteed to fail at runtime.
Comment 2 Benoit Jacob 2011-11-09 04:34:20 UTC
Note that abort() is not an option here: we must generate a bad_alloc exception which is tricky when compiling with -fno-exceptions. The only way is to do a huge new[].
Comment 3 Aaron Lindsay 2011-11-09 04:40:04 UTC
Neither of those work, they still complain about being too large.

However, this does:
size_t v = -1;
new int[v];

Tried it with various optimization levels and it compiles (and runs resulting in a bad_alloc) on all of them.
Comment 4 Gael Guennebaud 2011-12-05 09:46:17 UTC
thanks for finding this, seems to be harmless so:

https://bitbucket.org/eigen/eigen/changeset/e0b15640d9d1/
changeset:   e0b15640d9d1
date:        2011-12-05 09:44:25
summary:     fig bug 373: compilation error with clang 2.9 when exceptions are disabled (cannot reproduce with clang 3.0 or 3.1)
Comment 5 Nobody 2019-12-04 11:15:09 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/373.

Note You need to log in before you can comment on or make changes to this bug.