D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 9773 - ref parameter with default value should not compile
Summary: ref parameter with default value should not compile
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: accepts-invalid, pull
Depends on:
Blocks:
 
Reported: 2013-03-21 01:00 UTC by Rob T
Modified: 2013-05-17 13:01 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Rob T 2013-03-21 01:00:44 UTC
This should not compile.

void f( ref string a = "" )
{
   a = "crash and burn";
}

int main()
{

  f(); // seg fault
  return 0;
}
Comment 2 Andrej Mitrovic 2013-04-03 00:10:22 UTC
(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'
}
Comment 3 github-bugzilla 2013-04-04 12:58:18 UTC
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
Comment 4 github-bugzilla 2013-05-15 01:10:00 UTC
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
Comment 5 github-bugzilla 2013-05-17 13:01:16 UTC
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