Prepping a patch for dmd to correct some of the C++11 Correctness issues.

I came across this set and am a bit hesitant to change it without knowing side effects.

/home/huhlig/Temp/d/ldc/dmd2/struct.c:239:14: error: case value evaluates to -1, which cannot be narrowed to type 'structalign_t' (aka 'unsigned int')
      [-Wc++11-narrowing]
        case STRUCTALIGN_DEFAULT:
             ^
/home/huhlig/Temp/d/ldc/dmd2/mars.h:308:29: note: expanded from macro 'STRUCTALIGN_DEFAULT' #define STRUCTALIGN_DEFAULT ~0 // magic value means "match whatever the underlying C compiler does"

void AggregateDeclaration::alignmember(
structalign_t alignment, // struct alignment that is in effect unsigned size, // alignment requirement of field
        unsigned *poffset)
{
//printf("alignment = %d, size = %d, offset = %d\n",alignment,size,offset);
    switch (alignment)
    {
        case 1:
            // No alignment
            break;

        case STRUCTALIGN_DEFAULT:
{ /* Must match what the corresponding C compiler's default
             * alignment behavior is.
             */
            assert(size != 3);
            unsigned sa = (size == 0 || 8 < size) ? 8 : size;
            *poffset = (*poffset + sa - 1) & ~(sa - 1);
            break;
        }

        default:
// Align on alignment boundary, which must be a positive power of 2 assert(alignment > 0 && !(alignment & (alignment - 1))); *poffset = (*poffset + alignment - 1) & ~(alignment - 1);
            break;
    }
}

Reply via email to