Jump to page: 1 2
Thread overview
[Issue 5708] New: Error in std.typecons when -release, -inline, and -noboundscheck are all enabled
Mar 06, 2011
Jonathan M Davis
Mar 06, 2011
Jonathan M Davis
Mar 06, 2011
kennytm@gmail.com
Mar 06, 2011
kennytm@gmail.com
Mar 06, 2011
kennytm@gmail.com
[Issue 5708] Incorrect string constant folding with -inline
Mar 15, 2011
Don
Apr 08, 2011
Nick Sabalausky
Apr 09, 2011
Don
May 30, 2011
Jimmy Cao
May 30, 2011
Don
May 30, 2011
Jimmy Cao
May 30, 2011
Jimmy Cao
May 30, 2011
Don
[Issue 5708] [CTFE] Incorrect string constant folding with -inline
Jun 26, 2011
Don
March 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5708

           Summary: Error in std.typecons when -release, -inline, and
                    -noboundscheck are all enabled
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: jmdavisProg@gmx.com


--- Comment #0 from Jonathan M Davis <jmdavisProg@gmx.com> 2011-03-05 17:00:59 PST ---
From Tom on D.Learn (and I've confirmed it on Linux with both -m32 and -m64):

Minimal test case:

import std.stdio;
import std.conv;

int main(string[] args) {
        int[string] t;
        writeln(text(t));
        return 0;
}

Tried:

dmd -O -release -inline -noboundscheck -c -Isrc src\main.d -> ERROR dmd    -release -inline -noboundscheck -c -Isrc src\main.d -> ERROR dmd -O          -inline -noboundscheck -c -Isrc src\main.d -> OK dmd -O -release         -noboundscheck -c -Isrc src\main.d -> OK dmd -O -release -inline                -c -Isrc src\main.d -> OK

Where ERROR is:

E:\d\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(364): expression
expected, not 'EOF'
E:\d\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(364): found 'EOF'
when expecting ']'
E:\d\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(364): found 'EOF'
when expecting ')' following template argument list
E:\d\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(364): found 'EOF'
when expecting ']'
E:\d\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(364): found 'EOF'
when expecting ')' following template argument list
E:\d\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(364): found 'EOF'
when expecting ']'
E:\d\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(364): found 'EOF'
when expecting ')' following template argument list
E:\d\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(364): found 'EOF'
when expecting ']'
E:\d\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(364): found 'EOF'
when expecting ')' following template argument list
E:\d\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(364): found 'EOF'
when expecting ']'
E:\d\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(364): found 'EOF'
when expecting ')' following template argument list
E:\d\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(364): found 'EOF'
when expecting ']'
E:\d\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(364): found 'EOF'
when expecting ')' following template argument list
E:\d\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(364): found 'EOF'
when expecting ']'
E:\d\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(364): found 'EOF'
when expecting ')' following template argument list
E:\d\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(364): found 'EOF'
when expecting ']'
E:\d\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(364): found 'EOF'
when expecting ')' following template argument list
E:\d\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(364): found 'EOF'
when expecting ']'
E:\d\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(364): found 'EOF'
when expecting ')' following template argument list
E:\d\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(364): found 'EOF'
when expecting ']'
E:\d\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(364): found 'EOF'
when expecting ')' following template argument list

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5708


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #1 from bearophile_hugs@eml.cc 2011-03-05 17:19:25 PST ---
Problem confirmed on Windows, DMD 2.052, compiled with: -inline -release -noboundscheck

A bit reduced code:


import std.conv: to;
void main() {
    int[string] aa;
    to!string(aa);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5708



--- Comment #2 from bearophile_hugs@eml.cc 2011-03-05 17:39:42 PST ---
More reduction:

import std.conv: to;
void main() {
    int[int] aa;
    foreach (v; aa)
        to!string("");
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5708



--- Comment #3 from Jonathan M Davis <jmdavisProg@gmx.com> 2011-03-05 17:59:42 PST ---
Well, given the error, it involves creating a tuple, which none of the code here is doing directly, so in theory, it should be possible to reduce it to code which creates a tuple, but I don't know how you'd do that in this case. I assume that v in the foreach loop is a tuple of the key and value, and that's probably where the problem is, but I don't use associative arrays all that often, and when I do, I rarely iterate over them, so I'm not sure. Regardless, if you're really trying to reuduce it, in theory, you should be able to reduce it down to the creation of a tuple with a particular set of types.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5708



--- Comment #4 from bearophile_hugs@eml.cc 2011-03-05 18:41:43 PST ---
(In reply to comment #3)
> I assume that v in the foreach loop is a tuple of the key and value,

It's just a value, so it's an int.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5708


kennytm@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kennytm@gmail.com


--- Comment #5 from kennytm@gmail.com 2011-03-06 00:43:01 PST ---
It has nothing to do with the AA. Also, -inline alone is actually enough to trigger this bug. This seems to be a problem in string pooling in compile time.


import std.conv;
import std.typecons;

void ik(T,U)(T t, U u) {
    Tuple!(T,U) x;
}
pragma(msg, ik!(string,string));

void main() {
    () { to!string("lit"); } ();
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5708



--- Comment #6 from kennytm@gmail.com 2011-03-06 00:53:53 PST ---
Further removing the Tuple:



import std.conv;

void ik(T)(T) {
    enum a = to!string("foo") ~ to!string("bar");
    static assert(a == "foobar");
}
alias ik!int ik2;

void main() {
    cast(void) () { to!string("lit"); };
}

As of 2.052 it asserts:

~/Downloads:911$ dmd -inline y.d
y.d(5): Error: static assert  ("foofoo" == "foobar") is false
y.d(7):        instantiated from here: ik!(int)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5708



--- Comment #7 from kennytm@gmail.com 2011-03-06 01:02:07 PST ---
Further removing all Phobos dependency:



string b(string s) { return s; }
string a(string s) { return b(s); }

void ik(T)(T) {
    enum p = a("foo");
    enum q = a("bar");
    static assert(q == "bar");
}
alias ik!int ik2;

void main() {
    cast(void) () { a("lit"); };
}



Currently asserts:

y.d(7): Error: static assert  ("foo" == "bar") is false
y.d(9):        instantiated from here: ik!(int)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 15, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5708


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au
            Summary|Error in std.typecons when  |Incorrect string constant
                   |-release, -inline, and      |folding with -inline
                   |-noboundscheck are all      |
                   |enabled                     |
           Severity|major                       |critical


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 08, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5708


Nick Sabalausky <cbkbbejeap@mailinator.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |cbkbbejeap@mailinator.com


--- Comment #8 from Nick Sabalausky <cbkbbejeap@mailinator.com> 2011-04-08 03:33:16 PDT ---
Don's still-in-progress CTFE overhaul seems to fix this: https://github.com/donc/dmd/tree/ctfemem

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2