Skip to content

Misleading comment in cparser/StructPassing.ml #318

Open
@sixcy

Description

@sixcy

In the case of a struct passing using SP_split_args, this code of cparser/StructPassing.ml is actually misleading

let classify_param env ty =
  if is_composite_type env ty then begin
    match !struct_passing_style with
    | SP_ref_callee -> Param_unchanged
    | SP_ref_caller -> Param_ref_caller
    | _ ->
      match sizeof env ty, alignof env ty with
      | Some sz, Some al ->
          Param_flattened ((sz + 3) / 4, sz, al)
      | _, _ ->
          Param_unchanged  (* should not happen *)
  end else
Param_unchanged

The should not happen part actually happens for the test in test/regression/struct2.c :

struct B;
int f(struct B);
struct B { double d; };
int g() { struct B b; return f(b); }

This can be tested by replacing Param_unchanged (*should not happen *) by a failwith "Should not happen", then attempting to compile test/regression/struct2.c, on the x86_32-linux architecture.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions