This bugzilla service is closed. All entries have been migrated to
Bug 1584 - Improve random (avoid undefined behavior).
Summary: Improve random (avoid undefined behavior).
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.4 (development)
Hardware: Other Linux
: Normal Compilation Problem
Assignee: Nobody
Depends on:
Reported: 2018-08-10 06:16 UTC by Alexey Frunze
Modified: 2019-12-04 17:51 UTC (History)
4 users (show)

patch with fix (4.77 KB, patch)
2018-08-10 06:16 UTC, Alexey Frunze
no flags Details | Diff

Description Alexey Frunze 2018-08-10 06:16:50 UTC
Created attachment 878 [details]
patch with fix

This fixes failures in test rand on MIPS32R5.

The failures are a result of undefined behavior in template<typename Scalar> struct random_default_impl<Scalar, false, true>.

With certain values of arguments x and y there's a signed integer overflow in expression ScalarX(y)-ScalarX(x). This showed with the particular compiler version we're using for MIPS32R5.

Also, the template wouldn't handle the whole range of Scalar when it's 64-bit (long long or __int64) on 32-bit CPUs. This should fix it as well.
Comment 1 Alexey Frunze 2018-08-27 22:54:21 UTC
Comment 2 Gael Guennebaud 2018-08-28 07:32:30 UTC
Thank you for the patch, looks good to me so I applied it in 3.3 and default branches:
Comment 3 Alexey Frunze 2018-08-28 08:51:14 UTC
Was removal of is_integral<> intended in 3.3? Just checking.
Comment 4 Gael Guennebaud 2018-08-28 10:59:12 UTC
I've been too fast, my bad
Comment 5 Nobody 2019-12-04 17:51:29 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to'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:

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