[Issue 8328] Wrong constness of autogenerated opEquals when fields' opEquals have mixed constness

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jun 30 18:05:07 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8328


Vladimir Panteleev <thecybershadow at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
                 CC|                            |thecybershadow at 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


--- Comment #4 from Vladimir Panteleev <thecybershadow at gmail.com> 2012-06-30 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: -------


More information about the Digitalmars-d-bugs mailing list