This should not compile. void f( ref string a = "" ) { a = "crash and burn"; } int main() { f(); // seg fault return 0; }
https://github.com/D-Programming-Language/dmd/pull/1829
(In reply to comment #0) > This should not compile. > > void f( ref string a = "" ) > { > a = "crash and burn"; > } > > int main() > { > > f(); // seg fault > return 0; > } P.S. isn't there a way we can put string literals in some kind of ROM on Windows? It's just insane that it doesn't crash on Windows (ancient problem, I know): import std.stdio; void f(ref string a = "") { a = "crash and burn"; } void main() { f(); writeln(""); // 'crash and burn' }
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/706b18758a63715aef4b1821e7b66b1d4e5ee467 fix Issue 9773 - ref parameter with default string literal should not compile https://github.com/D-Programming-Language/dmd/commit/630e484c7e20cb156bf71404a342a8b98459cfde Merge pull request #1829 from 9rnsr/fix9773 Issue 9773 - ref parameter with default string literal should not compile
Commit pushed to 2.063 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/fe00d71443844f0261e0dd39b9c97ed3172b8527 Merge pull request #1829 from 9rnsr/fix9773 Issue 9773 - ref parameter with default string literal should not compile
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/fe00d71443844f0261e0dd39b9c97ed3172b8527 Merge pull request #1829 from 9rnsr/fix9773