[Issue 15241] New: struct literal implicitly converts void* to size_t
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Fri Oct 23 02:38:22 PDT 2015
    
    
  
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 at puremagic.com
          Reporter: anoneuron at 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.
--
    
    
More information about the Digitalmars-d-bugs
mailing list