Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
3cf48713
Commit
3cf48713
authored
Jun 29, 2020
by
Rory OConnell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Work around more MSC optimzer bugs
parent
6d565211
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
4 deletions
+22
-4
mrbgems/mruby-random/src/random.c
mrbgems/mruby-random/src/random.c
+22
-4
No files found.
mrbgems/mruby-random/src/random.c
View file @
3cf48713
...
...
@@ -220,12 +220,30 @@ mrb_ary_shuffle_bang(mrb_state *mrb, mrb_value ary)
/*
* MSC compiler bug generating invalid instructions with optimization
* enabled
* enabled. MSC errantly uses a hardcoded value with optimizations on
* when using a fixed value from a union.
* Creating a temp volatile variable and reassigning back to the original
* value tricks the compiler to not perform this optimization;
*/
#if defined _MSC_VER && _MSC_VER >= 1923
volatile
mrb_value
rr
;
rr
=
r
;
r
=
rr
;
/* C++ will not cast away volatile easily, so we cannot do something like
* volatile mrb_value rr = r; r = (mrb_value)rr; with C++.
* That cast does work with C.
* We also have to trick the compiler to not optimize away the const_cast entirely
* by creating and manipulating an intermediate volatile pointer.
*/
volatile
mrb_value
*
v_r
;
volatile
mrb_int
ii
;
mrb_value
*
p_r
;
v_r
=
&
r
;
ii
=
2
;
v_r
=
v_r
+
2
;
#if defined __cplusplus
p_r
=
const_cast
<
mrb_value
*>
(
v_r
-
ii
);
#else
p_r
=
(
mrb_value
*
)
v_r
-
ii
;
#endif
r
=
*
p_r
;
#endif
if
(
RARRAY_LEN
(
ary
)
>
1
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment