Skip to content

Commit

Permalink
Die in CStruct if native type isn't a multiple of 8 bits wide.
Browse files Browse the repository at this point in the history
  • Loading branch information
arnsholt committed Feb 2, 2013
1 parent 59a19e2 commit 96581f1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/6model/reprs/CStruct.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ static void compute_allocation_strategy(PARROT_INTERP, PMC *WHAT, CStructREPRDat
* that get_attribute_ref can find it later. */
bits = spec.bits;
align = spec.align;

if (bits % 8) {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"CStruct only supports native types that are a multiple of 8 bits wide (was passed: %ld)", bits);
}

repr_data->attribute_locations[i] = (bits << CSTRUCT_ATTR_SHIFT) | CSTRUCT_ATTR_IN_STRUCT;
repr_data->flattened_stables[i] = STABLE(type);
if (REPR(type)->initialize) {
Expand Down

0 comments on commit 96581f1

Please sign in to comment.