<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - wasm32: return_call_indirect type mismatch"
   href="https://bugs.llvm.org/show_bug.cgi?id=45007">45007</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>wasm32: return_call_indirect type mismatch
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>9.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>mail@daniel-mendler.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>$ clang-9 -O3 -ffreestanding -nostdinc -nostdlib --target=wasm32 -mtail-call
test.c -o test.wasm

Running the file test.wasm using `node --experimental-wasm-return_call`
produces a type mismatch error. Looking into the produced wasm code using
wabt-objdump there is indeed a mismatch `return_call_indirect 0 0` refers to
the type `() -> nil` instead of `() -> i32` as it should be.

---
// test.c
typedef int (*Fn)(void);

int g(void) {
    return 0;
}

Fn p = g;

int f(void) {
    return p();
}

void _start() {
    f();
}
---

A variation of the program using attribute(noinline) also does not work:

---
// test.c
typedef int (*Fn)(void);

int g(void) {
    return 0;
}

Fn p = g;

__attribute__((noinline)) int f(void) {
    return p();
}

void _start() {
    f();
}
---</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>