D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5369 - Segfault with pure auto function in separate module
Summary: Segfault with pure auto function in separate module
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Linux
: P2 normal
Assignee: No Owner
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2010-12-24 02:01 UTC by Stanislav Blinov
Modified: 2012-01-28 15:15 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Stanislav Blinov 2010-12-24 02:01:50 UTC
When a module has a non-templated function that is pure and has auto result type, and at least one parameter, compiler segfaults when compiling another module that imports the first and invokes the function.

Test case:
---
module mod;

// parameter type doesn't matter,
// as long as there is at least one parameter
// and function is not templated
pure auto foo(bool b)
{
    return 1;
}

module main;
import mod;

void main()
{
    foo(true);
}
---
$ dmd -v test.d mod.d

binary    dmd
version   v2.051
config    /home/user/dmd.conf
parse     test
parse     mod
importall test
import    object	(/home/user/dmd2/src/druntime/import/object.di)
importall mod
semantic  test
semantic  mod
semantic2 test
semantic2 mod
semantic3 test
Segmentation fault

Removing pure or parameters or replacing auto with concrete type, or making function templated, resolves segfault. If the function is defined and used in the same module that is being compiled, segfault doesn't occur either.
Comment 1 Stanislav Blinov 2010-12-24 02:04:53 UTC
Sorry, test.d should be main.d
Comment 2 Brad Roberts 2011-02-06 15:39:11 UTC
Mass migration of bugs marked as x86-64 to just x86.  The platform run on isn't what's relevant, it's if the app is a 32 or 64 bit app.
Comment 3 Don 2011-02-10 12:41:17 UTC
Not confirmed -- cannot reproduce on Windows. Maybe Linux-specific?
On Windows, I just get:
test.d(9): Error: forward reference to foo
But no segfault.
Comment 4 Walter Bright 2012-01-28 15:15:24 UTC
Cannot reproduce. Works on Windows, Linux and OS X.