View mode: basic / threaded / horizontal-split · Log in · Help
September 30, 2012
[Issue 8741] New: [CTFE] Incorrect static array assign results in constructor
http://d.puremagic.com/issues/show_bug.cgi?id=8741

          Summary: [CTFE] Incorrect static array assign results in
                   constructor
          Product: D
          Version: D2
         Platform: All
       OS/Version: All
           Status: NEW
         Severity: major
         Priority: P2
        Component: DMD
       AssignedTo: nobody@puremagic.com
       ReportedBy: peter.alexander.au@gmail.com


--- Comment #0 from Peter Alexander <peter.alexander.au@gmail.com> 2012-09-30 16:42:16 PDT ---
struct Vec2
{
   this(float x)
   {
       m[0] = x;
       m[1] = x;
   }
   float[2] m;
   static Vec2 zeroes = Vec2(0);
}

void main()
{
   import std.stdio;
   writeln(Vec2.zeroes);
}

Output is:
Vec2([0, nan])

http://dpaste.dzfl.pl/77058efc

Using two parameters for the constructor makes the bug go away:
http://dpaste.dzfl.pl/7ea20ba0

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 02, 2012
[Issue 8741] wrong code for struct member initialized using struct constructor
http://d.puremagic.com/issues/show_bug.cgi?id=8741


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

          What    |Removed                     |Added
----------------------------------------------------------------------------
          Keywords|                            |wrong-code
                CC|                            |clugdbug@yahoo.com.au
           Summary|[CTFE] Incorrect static     |wrong code for struct
                  |array assign results in     |member initialized using
                  |constructor                 |struct constructor


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2012-10-02 00:04:08 PDT ---
Was "CTFE: Incorrect static array assign results in constructor"

This doesn't involve CTFE, it's a semantic error. It is deciding if Vec2(0) is
a struct literal or a constructor, before it has worked out that Vec2 even has
a constructor. So it decides (incorrectly) that it's a struct literal.
It doesn't require static arrays, either. The constructor just doesn't get
called at all.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 02, 2012
[Issue 8741] wrong code for struct member initialized using struct constructor
http://d.puremagic.com/issues/show_bug.cgi?id=8741


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

          What    |Removed                     |Added
----------------------------------------------------------------------------
          Keywords|                            |pull


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2012-10-02 00:26:26 PDT ---
https://github.com/D-Programming-Language/dmd/pull/1157

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 03, 2013
[Issue 8741] wrong code for struct member initialized using struct constructor
http://d.puremagic.com/issues/show_bug.cgi?id=8741



--- Comment #3 from github-bugzilla@puremagic.com 2013-01-02 20:54:43 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/39207df0a43e1a39a4dcd169505758884cb992d3
Fix issue 8741 wrong code for struct member init using struct ctor

Generate an error if we need to decide if it is a ctor or not, when we
haven't determined the size yet.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 03, 2013
[Issue 8741] wrong code for struct member initialized using struct constructor
http://d.puremagic.com/issues/show_bug.cgi?id=8741


Walter Bright <bugzilla@digitalmars.com> changed:

          What    |Removed                     |Added
----------------------------------------------------------------------------
            Status|NEW                         |RESOLVED
                CC|                            |bugzilla@digitalmars.com
        Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 16, 2013
[Issue 8741] wrong code for struct member initialized using struct constructor
http://d.puremagic.com/issues/show_bug.cgi?id=8741


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

          What    |Removed                     |Added
----------------------------------------------------------------------------
                CC|                            |sludwig@outerproduct.org


--- Comment #4 from Don <clugdbug@yahoo.com.au> 2013-01-16 03:07:00 PST ---
*** Issue 3863 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 17, 2013
[Issue 8741] wrong code for struct member initialized using struct constructor
http://d.puremagic.com/issues/show_bug.cgi?id=8741


Kenji Hara <k.hara.pg@gmail.com> changed:

          What    |Removed                     |Added
----------------------------------------------------------------------------
                CC|                            |magnus_lindberg@live.se


--- Comment #5 from Kenji Hara <k.hara.pg@gmail.com> 2013-02-17 02:08:21 PST ---
*** Issue 9519 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Top | Discussion index | About this forum | D home