www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8581] New: Internal error: backend/cod1.c 1677 on structs with bitfields (when compile with release or optimize parameter)

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

           Summary: Internal error: backend/cod1.c 1677 on structs with
                    bitfields (when compile with release or optimize
                    parameter)
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: kozzi11 gmail.com



Problematic code below:


import std.bitmanip;


struct Record {
    mixin(bitfields!(
        bool , "a"    , 1,
        bool , "b"          , 1,
        bool , "c"           , 1,
        bool , "d", 1,
        bool , "e", 1,
        bool , "f"     , 1,
        bool , "g"      , 1,
        bool , "h"      , 1
    ));
}


enum RECORD_LENGTH    = 16;
enum EMPTY_RECORD_BITMASK = 0xff;

void main(string[] args)
{  
    ubyte[] aw_buffer = cast(ubyte[])"Some data from file for e.g.";

    Record o_currentRecord;

    auto n_recordCount = aw_buffer.length / RECORD_LENGTH;
    auto p_records = cast(Record*)aw_buffer.ptr;

    foreach(n_index; 0 .. n_recordCount) {

        o_currentRecord = p_records[n_index];
        bool isEmptyRecord = *(cast(ubyte * )(&(o_currentRecord.a))) ==
EMPTY_RECORD_BITMASK;

        if(isEmptyRecord) { // problematic place
        } else if (o_currentRecord.a == 0 && !o_currentRecord.b) { //
problematic place
        } else if (o_currentRecord.a == 1 && o_currentRecord.d == 0) { //
problematic place
        } else {
        }

        //BUT THIS WORKS //
        /*
            if(isEmptyRecord) {
            }
        */

        //AND THIS WORKS TOO//
        /*
            if(any other condition expresion) { // problematic line
            } else if (o_currentRecord.a == 0 && !o_currentRecord.b) {
            } else if (o_currentRecord.a == 1 && o_currentRecord.d == 0) {
            } else {
            }
        */
    }  
}

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