Consistent bugs with dmd -O -inline in a large project
Chris via Digitalmars-d
digitalmars-d at puremagic.com
Thu Oct 16 07:46:24 PDT 2014
Ok. It was the compiler. To reproduce the error, I wrote a small
example:
import std.stdio;
import std.algorithm : sort;
enum {
Answers = [
"Are you corrupt?" : "No!",
"Will you resign?" : "No!"
]
}
void main() {
auto journalist = new myClass;
journalist.printAnswers();
}
class myClass {
mixin News;
this() {
Questions = Answers.keys();
// Only here to do what my program does
sort!((a, b) => a.length > b.length)(Questions);
}
protected void printAnswers() {
foreach (q; Questions) {
writefln("Q: %s\nA: %s", q, getAnswer(q));
}
}
}
mixin template News() {
string[] Questions;
auto getAnswer(string q) {
return Answers[q];
}
}
[version 2.065]
$ dmd optimizer.d -O -release -inline -noboundscheck
$ ./optimizer
$ Segmentation fault (core dumped)
[versino 2.066]
$ dmd optimizer.d -O -release -inline -noboundscheck
$ ./optimizer
Q: Are you corrupt?
A: No!
Q: Will you resign?
A: No!
$
Sorry, I couldn't try it with 2.066 first, because I still have
to update my code base.
More information about the Digitalmars-d
mailing list