www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8328] New: Mind Blowing error (possibly in DMD or std.variant)

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8328

           Summary: Mind Blowing error (possibly in DMD or std.variant)
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: IcePapih gmail.com



---
Created an attachment (id=1122)
The minimal source tree that is giving the error

Hello lovely D folks!

I have been dealing with this incredibly strange error that I don't really even
know how to describe because I can't understand what's causing it. I can really
just show you.

Here's the quick scoop if you don't want to download stuff etc:
https://gist.github.com/3025946

Anyways here's everything I can say,

Assuming the following tree:

./
├── bin
├── lib
│   ├── import
│   │   └── gl3n
│   │       ├── color
│   │       │   └── hsv.di
│   │       ├── interpolate.di
│   │       ├── linalg.di
│   │       ├── math.di
│   │       └── util.di
│   ├── libgl3n-dmd.a
|
├── reducedt.reduced
│   ├── build (HERE IS WHERE YOU RUN THE COMPILE COMMAND..)
│   │   └── empty
│   └── torment
│       ├── component
│       │   ├── all.d
│       │   ├── component.d
│       │   └── render.d
│       ├── entity
│       │   └── camera.d
│       ├── math
│       │   └── vector.d
│       └── scene
│           └── scene.d

compiling with "dmd -g -debug -property -w -wi -I../../lib/import
-L-L../../lib/ -L-lgl3n-dmd -of../../bin/execute_me ../torment/component/all.d
../torment/component/component.d ../torment/component/render.d
../torment/scene/scene.d ../torment/math/vector.d ../torment/entity/camera"
outputs the following error:

../torment/scene/scene.d(3): Error: cannot compare
const(VariantN!(1LU,RenderComponent)[]) and
const(VariantN!(1LU,RenderComponent)[])

The line it's complaining about (3) looks like: 
struct Scene {

And I don't know what to make of that. I've tried reducing (in fact the tree
you are looking at is *very* reduced) so I have the minimal case of failure
here. I have attached the tree (including lib imports and the .a file compiled
for 64bit linux) so you can try compiling for yourself. I've tried it on two
computers - both 64bit linux though so I don't know if that's got anything to
do with the problem.

At this point I don't know if this is my fault or dmd's fault or phobos'. I
assume it's the compiler but I can't know for sure. I marked this bug as
critical because it has completely stalled the development of my project for
two days now. And that does not give me a good feeling at all. I really *need*
to get on with it!

I just feel like this either is out of my hands, or just me doing something
obviously wrong and is not getting it. But nobody in irc seems to know what's
wrong either. So I am submitting this here.

Thank you!

-- Isak Andersson

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 30 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8328


Jonathan M Davis <jmdavisProg gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg gmx.com



PDT ---
Have you tried the latest master from github?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 30 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8328




---

 Have you tried the latest master from github?
You mean DMD? No I have not. But I've considered since I really need to keep up development! Should I? Or are there any errors visible from the code I posted? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 30 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8328




PDT ---
You should just try the latest master. I honestly don't want to spend the time
digging through your code to try and figure out what's wrong with it. It's much
simpler if you can present an example which exhibits the problem. But for all I
know, your problem has been fixed in git already, and it'll be easier for you
to test that than anyone else.

You'll need to grab dmd, druntime, and Phobos from here:

https://github.com/D-Programming-Language

build them all, and then use those, which would involve building dmd, then
making sure that your system is using the new dmd, then building druntime and
Phobos and making sure that your system is using them (which involves altering
your dmd.conf or sc.ini file). It's not hard to deal with (particularly in
Linux thanks to symlinks) once you've got it set up, but it might be a bit of a
pain to figure out exactly

Alternatively, you could use dvm ( https://github.com/jacob-carlborg/dvm ) to
download and build it using its compile command. I've never used dvm, but it's
supposed to be quite easy to use. It's a tool for managing dmd, and will allow
you to install a specific compiler version or build the latest from github.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 30 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8328


Vladimir Panteleev <thecybershadow gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
                 CC|                            |thecybershadow gmail.com
           Platform|x86_64                      |All
            Summary|Mind Blowing error          |Wrong constness of
                   |(possibly in DMD or         |autogenerated opEquals when
                   |std.variant)                |fields' opEquals have mixed
                   |                            |constness
         OS/Version|Linux                       |All
           Severity|critical                    |normal



18:07:42 PDT ---
Minimal testcase:
---
struct S1 { bool opEquals(S1 o)       { return true; } }
struct S2 { bool opEquals(S2 o) const { return true; } }
struct X { S1 s1; S2 s2; }
---

The problem seems to be that DMD decides that the autogenerated opEquals should
be "const", and then fails when it tries to call S1's opEquals.

The solution for this particular problem would be to reverse the
common-denominator logic, although this won't work if immutable is thrown into
the mix. A better error message would also be an improvement.

Workaround:
Write your own non-const opEquals in X.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 30 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8328




18:16:47 PDT ---
Still happens in DMD head (7307e7190d9).

The submitter's issue could also be resolved by making Variant const-correct. I
don't know what that would involve; I assume the issue is non-trivial, seeing
that this hasn't been done yet.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 30 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8328




---
Huge thanks to Vladimir for figuring this out! This means I'll be able to go to
sleep without worrying about being concerned about solving this.

I hope this can be resolved so that others don't fall into the same trap,
because it was definitely not easy to get out of for me who is new to D!

Thank you :)

-- Isak Andersson

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 30 2012