cib icon indicating copy to clipboard operation
cib copied to clipboard

RuntimeError: index out of bounds

Open xplorld opened this issue 4 years ago • 4 comments

On the website https://tbfleming.github.io/cib/, keeping the example string-sorting code as-is, click "Compile" -> "wasm size: 14001", click "Run" -> "RuntimeError: index out of bounds"

Browser I use: Chrome: Version 83.0.4103.116 (Official Build) (64-bit) Firefox: 78.0.1 (64-bit)

xplorld avatar Jul 12 '20 05:07 xplorld

Further investigations: Changing cout to printf works. Other examples with cout fails, and without cout, succeeds.

It seems there are something wrong with cout.

xplorld avatar Jul 12 '20 05:07 xplorld

This is such a cool project, and I would love for this to get fixed, because it has great pedagogical uses for teaching C++ and giving students immediate feedback in the browser, regardless of their runtime environment.

I should also note some strange behavior in the output console even with printf. Here's a simple code snippet I'm testing

#include <stdio.h>

int main() {
    printf("Hello world\n");
    for (int i = 0; i < 10; i++) {
        printf("%i ", i);
    }
}

The first time I run it, I see

Hello world

the second time I run it, I see

0 1 2 3 4 5 6 7 8 9 Hello world

ctralie avatar Oct 11 '20 16:10 ctralie

@ctralie If you put a cout<<endl at the end of main(), then this problem wouldn't occur. I may have fixed this in my stdin PR, but I forget because that was a long time ago.

arasouli91 avatar Oct 12 '20 04:10 arasouli91

Ah yes nice that did it, thanks @arasouli91!

ctralie avatar Oct 14 '20 12:10 ctralie