Skip to content

Crash on literal strings #11

@Blei

Description

@Blei

The following program crashes while being parsed (?) by clang:

struct device_information {
  unsigned id_lo, id_hi;
  unsigned version;
  unsigned manufacturer_lo, manufacturer_hi;
};

void get_device_information(unsigned device_number,
                            struct device_information *info) {
  asm volatile (
      "HWQ %5\n"
      "SET %0, A\n"
      "SET %1, B\n"
      "SET %2, C\n"
      "SET %3, X\n"
      "SET %4, Y"
      :
      "=g" (info->id_lo),
      "=g" (info->id_hi),
      "=g" (info->version),
      "=g" (info->manufacturer_lo),
      "=g" (info->manufacturer_hi)
      :
      "r" (device_number)
      :
      // Clobbered registers
      "A", "B", "C", "X", "Y");
}

If the asm string is concatenated into one line ("HWQ %5\nSET %0, A\nSET %1, B\nSET %2, C\nSET %3, X\nSET %4, Y"), everything works as it should.

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