www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15241] New: struct literal implicitly converts void* to size_t

https://issues.dlang.org/show_bug.cgi?id=15241

          Issue ID: 15241
           Summary: struct literal implicitly converts void* to size_t
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: anoneuron gmail.com

http://dpaste.dzfl.pl/6001f46873fd

On my 32-bit x86 system (DMD v2.068.2), the results are slightly different from
dpaste's compiler:

    struct HandleT {
        size_t Val;
    };

    void main() {
        auto h1 = HandleT( cast(const void*) 1 ); // allowed

        auto h2 = HandleT( cast(void*) 1 ); // allowed

        auto p1 = cast(const void*) 1;
        auto h3 = HandleT( p1 ); // allowed

        auto p2 = cast(void*) 1;
        auto h4 = HandleT( p2 ); // rejected
    };

const(void*) is allowed but void* is rejected O.o
Obviously none of these expressions should compile.

--
Oct 23 2015