This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
View | Details | Raw Unified | Return to bug 89 | Differences between
and this patch

Collapse All | Expand All

(-)a/Eigen/Core (-1 / +5 lines)
Lines 151-169 Link Here
151
#include <iosfwd>
151
#include <iosfwd>
152
#include <cstring>
152
#include <cstring>
153
#include <string>
153
#include <string>
154
#include <limits>
154
#include <limits>
155
#include <climits> // for CHAR_BIT
155
#include <climits> // for CHAR_BIT
156
// for min/max:
156
// for min/max:
157
#include <algorithm>
157
#include <algorithm>
158
158
159
#if !EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO
160
#include <iostream> // for custom assert implementation
161
#endif
162
159
// for outputting debug info
163
// for outputting debug info
160
#ifdef EIGEN_DEBUG_ASSIGN
164
#ifdef EIGEN_DEBUG_ASSIGN
161
#include<iostream>
165
#include <iostream>
162
#endif
166
#endif
163
167
164
// required for __cpuid, needs to be included after cmath
168
// required for __cpuid, needs to be included after cmath
165
#if defined(_MSC_VER) && (defined(_M_IX86)||defined(_M_X64))
169
#if defined(_MSC_VER) && (defined(_M_IX86)||defined(_M_X64))
166
  #include <intrin.h>
170
  #include <intrin.h>
167
#endif
171
#endif
168
172
169
#if (defined(_CPPUNWIND) || defined(__EXCEPTIONS)) && !defined(EIGEN_NO_EXCEPTIONS)
173
#if (defined(_CPPUNWIND) || defined(__EXCEPTIONS)) && !defined(EIGEN_NO_EXCEPTIONS)
(-)a/Eigen/src/Core/util/Macros.h (-33 / +78 lines)
Lines 29-48 Link Here
29
#define EIGEN_WORLD_VERSION 2
29
#define EIGEN_WORLD_VERSION 2
30
#define EIGEN_MAJOR_VERSION 93
30
#define EIGEN_MAJOR_VERSION 93
31
#define EIGEN_MINOR_VERSION 0
31
#define EIGEN_MINOR_VERSION 0
32
32
33
#define EIGEN_VERSION_AT_LEAST(x,y,z) (EIGEN_WORLD_VERSION>x || (EIGEN_WORLD_VERSION>=x && \
33
#define EIGEN_VERSION_AT_LEAST(x,y,z) (EIGEN_WORLD_VERSION>x || (EIGEN_WORLD_VERSION>=x && \
34
                                      (EIGEN_MAJOR_VERSION>y || (EIGEN_MAJOR_VERSION>=y && \
34
                                      (EIGEN_MAJOR_VERSION>y || (EIGEN_MAJOR_VERSION>=y && \
35
                                                                 EIGEN_MINOR_VERSION>=z))))
35
                                                                 EIGEN_MINOR_VERSION>=z))))
36
#ifdef __GNUC__
36
#ifdef __GNUC__
37
  #define EIGEN_GNUC_AT_LEAST(x,y) ((__GNUC__>=x && __GNUC_MINOR__>=y) || __GNUC__>x)
37
  #define EIGEN_GNUC_AT_LEAST(x,y) ((__GNUC__==x && __GNUC_MINOR__>=y) || __GNUC__>x)
38
#else
38
#else
39
  #define EIGEN_GNUC_AT_LEAST(x,y) 0
39
  #define EIGEN_GNUC_AT_LEAST(x,y) 0
40
#endif
40
#endif
41
 
42
#ifdef __GNUC__
43
  #define EIGEN_GNUC_AT_MOST(x,y) ((__GNUC__==x && __GNUC_MINOR__<=y) || __GNUC__<x)
44
#else
45
  #define EIGEN_GNUC_AT_MOST(x,y) 0
46
#endif
47
48
#if EIGEN_GNUC_AT_MOST(4,3)
49
  // see bug 89
50
  #define EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO 0
51
#else
52
  #define EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO 1
53
#endif
41
54
42
#if defined(__GNUC__) && (__GNUC__ <= 3)
55
#if defined(__GNUC__) && (__GNUC__ <= 3)
43
#define EIGEN_GCC3_OR_OLDER 1
56
#define EIGEN_GCC3_OR_OLDER 1
44
#else
57
#else
45
#define EIGEN_GCC3_OR_OLDER 0
58
#define EIGEN_GCC3_OR_OLDER 0
46
#endif
59
#endif
47
60
48
// 16 byte alignment is only useful for vectorization. Since it affects the ABI, we need to enable
61
// 16 byte alignment is only useful for vectorization. Since it affects the ABI, we need to enable
Lines 104-144 Link Here
104
  *   - single precision Cwise::sin() and Cwise::cos() when SSE vectorization is enabled.
117
  *   - single precision Cwise::sin() and Cwise::cos() when SSE vectorization is enabled.
105
  */
118
  */
106
#ifndef EIGEN_FAST_MATH
119
#ifndef EIGEN_FAST_MATH
107
#define EIGEN_FAST_MATH 1
120
#define EIGEN_FAST_MATH 1
108
#endif
121
#endif
109
122
110
#define EIGEN_DEBUG_VAR(x) std::cerr << #x << " = " << x << std::endl;
123
#define EIGEN_DEBUG_VAR(x) std::cerr << #x << " = " << x << std::endl;
111
124
112
#ifdef NDEBUG
125
// concatenate two tokens
113
# ifndef EIGEN_NO_DEBUG
126
#define EIGEN_CAT2(a,b) a ## b
114
#  define EIGEN_NO_DEBUG
127
#define EIGEN_CAT(a,b) EIGEN_CAT2(a,b)
115
# endif
116
#endif
117
128
118
#ifndef eigen_assert
129
// convert a token to a string
119
#ifdef EIGEN_NO_DEBUG
130
#define EIGEN_MAKESTRING2(a) #a
120
#define eigen_assert(x)
131
#define EIGEN_MAKESTRING(a) EIGEN_MAKESTRING2(a)
121
#else
122
#define eigen_assert(x) assert(x)
123
#endif
124
#endif
125
126
#ifdef EIGEN_INTERNAL_DEBUGGING
127
#define eigen_internal_assert(x) eigen_assert(x)
128
#else
129
#define eigen_internal_assert(x)
130
#endif
131
132
#ifdef EIGEN_NO_DEBUG
133
#define EIGEN_ONLY_USED_FOR_DEBUG(x) (void)x
134
#else
135
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
136
#endif
137
132
138
// EIGEN_ALWAYS_INLINE_ATTRIB should be use in the declaration of function
133
// EIGEN_ALWAYS_INLINE_ATTRIB should be use in the declaration of function
139
// which should be inlined even in debug mode.
134
// which should be inlined even in debug mode.
140
// FIXME with the always_inline attribute,
135
// FIXME with the always_inline attribute,
141
// gcc 3.4.x reports the following compilation error:
136
// gcc 3.4.x reports the following compilation error:
142
//   Eval.h:91: sorry, unimplemented: inlining failed in call to 'const Eigen::Eval<Derived> Eigen::MatrixBase<Scalar, Derived>::eval() const'
137
//   Eval.h:91: sorry, unimplemented: inlining failed in call to 'const Eigen::Eval<Derived> Eigen::MatrixBase<Scalar, Derived>::eval() const'
143
//    : function body not available
138
//    : function body not available
144
#if EIGEN_GNUC_AT_LEAST(4,0)
139
#if EIGEN_GNUC_AT_LEAST(4,0)
Lines 170-185 Link Here
170
165
171
// this macro allows to get rid of linking errors about multiply defined functions.
166
// this macro allows to get rid of linking errors about multiply defined functions.
172
//  - static is not very good because it prevents definitions from different object files to be merged.
167
//  - static is not very good because it prevents definitions from different object files to be merged.
173
//           So static causes the resulting linked executable to be bloated with multiple copies of the same function.
168
//           So static causes the resulting linked executable to be bloated with multiple copies of the same function.
174
//  - inline is not perfect either as it unwantedly hints the compiler toward inlining the function.
169
//  - inline is not perfect either as it unwantedly hints the compiler toward inlining the function.
175
#define EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
170
#define EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
176
#define EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS inline
171
#define EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS inline
177
172
173
#ifdef NDEBUG
174
# ifndef EIGEN_NO_DEBUG
175
#  define EIGEN_NO_DEBUG
176
# endif
177
#endif
178
179
// eigen_plain_assert is where we implement the workaround for the assert() bug in GCC <= 4.3, see bug 89
180
#ifdef EIGEN_NO_DEBUG
181
  #define eigen_plain_assert(x)
182
#else
183
  #if EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO
184
    namespace Eigen {
185
    namespace internal {
186
    inline bool copy_bool(bool b) { return b; }
187
    }
188
    }
189
    #define eigen_plain_assert(x) assert(x)
190
  #else
191
    // work around bug 89
192
    namespace Eigen {
193
    namespace internal {
194
    // trivial function copying a bool. Must be EIGEN_DONT_INLINE, so we implement it after including Eigen headers.
195
    // see bug 89.
196
    namespace {
197
    EIGEN_DONT_INLINE bool copy_bool(bool b) { return b; }
198
    }
199
    inline void assert_fail(const char *condition, const char *function, const char *file, int line)
200
    {
201
      std::cerr << "assertion failed: " << condition << " in function " << function << " at " << file << ":" << line << std::endl;
202
      abort();
203
    }
204
    }
205
    }
206
    #define eigen_plain_assert(x) \
207
      do { \
208
        if(!Eigen::internal::copy_bool(x)) \
209
          Eigen::internal::assert_fail(EIGEN_MAKESTRING(x), __PRETTY_FUNCTION__, __FILE__, __LINE__); \
210
      } while(false)
211
  #endif
212
#endif
213
214
// eigen_assert can be overridden
215
#ifndef eigen_assert
216
#define eigen_assert(x) eigen_plain_assert(x)
217
#endif
218
219
#ifdef EIGEN_INTERNAL_DEBUGGING
220
#define eigen_internal_assert(x) eigen_assert(x)
221
#else
222
#define eigen_internal_assert(x)
223
#endif
224
225
#ifdef EIGEN_NO_DEBUG
226
#define EIGEN_ONLY_USED_FOR_DEBUG(x) (void)x
227
#else
228
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
229
#endif
230
178
#if (defined __GNUC__)
231
#if (defined __GNUC__)
179
#define EIGEN_DEPRECATED __attribute__((deprecated))
232
#define EIGEN_DEPRECATED __attribute__((deprecated))
180
#elif (defined _MSC_VER)
233
#elif (defined _MSC_VER)
181
#define EIGEN_DEPRECATED __declspec(deprecated)
234
#define EIGEN_DEPRECATED __declspec(deprecated)
182
#else
235
#else
183
#define EIGEN_DEPRECATED
236
#define EIGEN_DEPRECATED
184
#endif
237
#endif
185
238
Lines 239-262 Link Here
239
#else
292
#else
240
#define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat()
293
#define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat()
241
#endif
294
#endif
242
#endif
295
#endif
243
296
244
// just an empty macro !
297
// just an empty macro !
245
#define EIGEN_EMPTY
298
#define EIGEN_EMPTY
246
299
247
// concatenate two tokens
248
#define EIGEN_CAT2(a,b) a ## b
249
#define EIGEN_CAT(a,b) EIGEN_CAT2(a,b)
250
251
// convert a token to a string
252
#define EIGEN_MAKESTRING2(a) #a
253
#define EIGEN_MAKESTRING(a) EIGEN_MAKESTRING2(a)
254
255
#if defined(_MSC_VER) && (!defined(__INTEL_COMPILER))
300
#if defined(_MSC_VER) && (!defined(__INTEL_COMPILER))
256
#define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
301
#define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
257
  using Base::operator =;
302
  using Base::operator =;
258
#else
303
#else
259
#define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
304
#define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
260
  using Base::operator =; \
305
  using Base::operator =; \
261
  EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) \
306
  EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) \
262
  { \
307
  { \
(-)a/test/main.h (-6 / +4 lines)
Lines 86-102 namespace Eigen Link Here
86
  // and might even introduce side effects that would hide
86
  // and might even introduce side effects that would hide
87
  // some memory errors.
87
  // some memory errors.
88
  #ifdef EIGEN_DEBUG_ASSERTS
88
  #ifdef EIGEN_DEBUG_ASSERTS
89
89
90
    namespace Eigen
90
    namespace Eigen
91
    {
91
    {
92
      namespace internal
92
      namespace internal
93
      {
93
      {
94
	static bool push_assert = false;
94
        static bool push_assert = false;
95
      }
95
      }
96
      static std::vector<std::string> eigen_assert_list;
96
      static std::vector<std::string> eigen_assert_list;
97
    }
97
    }
98
98
99
    #define eigen_assert(a)                       \
99
    #define eigen_assert(a)                       \
100
      if( (!(a)) && (!no_more_assert) )     \
100
      if( (!(a)) && (!no_more_assert) )     \
101
      { \
101
      { \
102
        if(report_on_cerr_on_assert_failure) \
102
        if(report_on_cerr_on_assert_failure) \
Lines 124-150 namespace Eigen Link Here
124
        } catch (Eigen::eigen_assert_exception) {                                        \
124
        } catch (Eigen::eigen_assert_exception) {                                        \
125
          Eigen::internal::push_assert = false; VERIFY(true);                                \
125
          Eigen::internal::push_assert = false; VERIFY(true);                                \
126
        }                                                                             \
126
        }                                                                             \
127
        Eigen::report_on_cerr_on_assert_failure = true;                               \
127
        Eigen::report_on_cerr_on_assert_failure = true;                               \
128
        Eigen::internal::push_assert = false;                                                \
128
        Eigen::internal::push_assert = false;                                                \
129
      }
129
      }
130
130
131
  #else // EIGEN_DEBUG_ASSERTS
131
  #else // EIGEN_DEBUG_ASSERTS
132
132
    // see bug 89. The copy_bool here is working around a bug in gcc <= 4.3
133
    #define eigen_assert(a) \
133
    #define eigen_assert(a) \
134
      if( (!(a)) && (!no_more_assert) )       \
134
      if( (!Eigen::internal::copy_bool(a)) && (!no_more_assert) )\
135
      {                                       \
135
      {                                       \
136
        Eigen::no_more_assert = true;         \
136
        Eigen::no_more_assert = true;         \
137
        if(report_on_cerr_on_assert_failure)  \
137
        if(report_on_cerr_on_assert_failure)  \
138
          assert(a);                          \
138
          eigen_plain_assert(a);              \
139
        else                                  \
139
        else                                  \
140
          throw Eigen::eigen_assert_exception(); \
140
          throw Eigen::eigen_assert_exception(); \
141
      }
141
      }
142
143
    #define VERIFY_RAISES_ASSERT(a) {                             \
142
    #define VERIFY_RAISES_ASSERT(a) {                             \
144
        Eigen::no_more_assert = false;                            \
143
        Eigen::no_more_assert = false;                            \
145
        Eigen::report_on_cerr_on_assert_failure = false;          \
144
        Eigen::report_on_cerr_on_assert_failure = false;          \
146
        try {                                                     \
145
        try {                                                     \
147
          a;                                                      \
146
          a;                                                      \
148
          VERIFY(Eigen::should_raise_an_assert && # a);           \
147
          VERIFY(Eigen::should_raise_an_assert && # a);           \
149
        }                                                         \
148
        }                                                         \
150
        catch (Eigen::eigen_assert_exception&) { VERIFY(true); }     \
149
        catch (Eigen::eigen_assert_exception&) { VERIFY(true); }     \
Lines 160-176 namespace Eigen Link Here
160
  #define VERIFY_RAISES_ASSERT(a) {}
159
  #define VERIFY_RAISES_ASSERT(a) {}
161
160
162
#endif // EIGEN_NO_ASSERTION_CHECKING
161
#endif // EIGEN_NO_ASSERTION_CHECKING
163
162
164
163
165
#define EIGEN_INTERNAL_DEBUGGING
164
#define EIGEN_INTERNAL_DEBUGGING
166
#include <Eigen/QR> // required for createRandomPIMatrixOfRank
165
#include <Eigen/QR> // required for createRandomPIMatrixOfRank
167
166
168
169
static void verify_impl(bool condition, const char *testname, const char *file, int line, const char *condition_as_string)
167
static void verify_impl(bool condition, const char *testname, const char *file, int line, const char *condition_as_string)
170
{
168
{
171
  if (!condition)
169
  if (!condition)
172
  {
170
  {
173
    std::cerr << "Test " << testname << " failed in " << file << " (" << line << ")" \
171
    std::cerr << "Test " << testname << " failed in " << file << " (" << line << ")" \
174
      << std::endl << "    " << condition_as_string << std::endl << std::endl; \
172
      << std::endl << "    " << condition_as_string << std::endl << std::endl; \
175
    abort();
173
    abort();
176
  }
174
  }

Return to bug 89