[Issue 9387] New: Compiler switch -O changes behavior of correct code
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 24 07:56:10 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9387
Summary: Compiler switch -O changes behavior of correct code
Product: D
Version: D2
Platform: x86_64
OS/Version: Mac OS X
Status: NEW
Severity: major
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: stephan.schiffels at mac.com
--- Comment #0 from Stephan <stephan.schiffels at mac.com> 2013-01-24 07:56:09 PST ---
Created an attachment (id=1182)
Source file with program that
The attached program implements a part of Brent's minimization algorithm for
one-dimensionsal functions. The code is from Numerical Recipes 3rd edition.
I use dmd 2.061/
When I run the program with "rdmd brent_test.d" it runs fine and gives the
correct result.
When I run it with optimization, i.e. with "rdmd -O brent_test.d", it behaves
differently. It enters some infinite loop and eventually throws the expected
exception for too many iterations.
You can see that I placed a writefln() into line 45, which outputs the value of
variable a. When you move this writefln statement just one line below, i.e.
below the if-statement, the code runs fine, even with optimization.
I colleague of mine suggested that there might be a bug related to a large
number of local variables. Maybe some limiting number of registers causes the
machine to cache things into memory and pulling them back in a wrong way or
something.
Appreciate help!
Stephan
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list