<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/57790>57790</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            inline asm behavior is different in msvc and clang-cl for jmp instruction
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          kin4stat
      </td>
    </tr>
</table>

<pre>
    The examples below work on MSVC and crash with a segfault on clang-cl
```cpp
#include <iostream>

void* f;

void foo() {
    std::cout << "test" << std::endl;
}

__declspec(naked) void foo_copy() {
    __asm {
        jmp f
    }
}

int main() {
    f = reinterpret_cast<void*>(&foo);

    foo_copy();
}
```

```cpp
#include <iostream>

void* f[2];

void foo() {
    std::cout << "test" << std::endl;
}

__declspec(naked) void foo_copy() {
    __asm {
        jmp [f + 1 * sizeof(*f)]
    }
}

int main() {
    f[1] = reinterpret_cast<void*>(&foo);

    foo_copy();
}
```

```cpp
#include <iostream>

void* f[2];

void foo() {
    std::cout << "test" << std::endl;
}

__declspec(naked) void foo_copy() {
    __asm {
        jmp f[1 * sizeof(*f)]
    }
}

int main() {
    f[1] = reinterpret_cast<void*>(&foo);

    foo_copy();
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztVU1v4yAQ_TX4ghph_JH44EM-trc97WqvEYZxTIPBApxs99fv2E2atsqtl1W1aGTsGZg3854FjVPP9c8OKPwW_WAg0AaMO9Oz80fqLP3-49eWCquo9CJ09KxjRwUNcGjFaOK0QhphDw_SELYjbE1K9mJyGC4enmkrzaiAkmyrXYgeRE-yb5fw_Dw5rQhf05Zkm49-2jpH-IrwipLlJUpxhKhItkaTboxTbjRKOI8QIk5Xz-sysMrc0i93b3H2ewXShAEkIllxBDXBXdH30g3P90rY70Xo37um8dQP2Mmr64b1HlTbSHuh7b3MLZa_ox5wDfjBQ9xLgW1l2wtTE3_TtnImp_pA25zhXd13Gr8q9Xbjp-UrNpwUuy-jIvaDSvANTenUX9B_wLVzjnU7sVrsPikzAqSY5b_a_4LasxpfRegE6rQss6xMS54nqs5UlVUiiToaqLU12gKdmGigEyftPNWBKt224AH70Jb24SRfjv7LCY_YfuZJW_wvRhm1s8noTd3FOIRJMP6IdsA7YmwW0vX4YczpOj0M3j2BRJ0fdQgjBHwplsuKJV1dtm2TNu1KCF40Wb7KRV6IShWMsaosGp4YgfdSqJFFJDHRNWecswpbY0WW54tqyZp0WabQ8AqYVCRngFKYxQS8cP6Q-HquoRkPAYNGhxhuQRGCPliAa34xxs75-qhtHqKIyVxvPRf7F7Lv8eA">