Created
February 11, 2018 00:23
-
-
Save TannerRogalsky/7fc22007b55a9a2f15a845b5a694d69a to your computer and use it in GitHub Desktop.
Emscripten producing invalid JS when unary operator is applied to static const instance property.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
class UnaryTest { | |
public: | |
static const UnaryTest STATIC_TEST; | |
double p; | |
UnaryTest(double p); | |
}; | |
const UnaryTest UnaryTest::STATIC_TEST(-1); | |
UnaryTest::UnaryTest(double inP) : p(inP) { } | |
int main(int, char**){ | |
double t = -UnaryTest::STATIC_TEST.p; | |
printf("%f\n", t); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _main($0,$1) { | |
$0 = $0|0; | |
$1 = $1|0; | |
var $2 = 0, $3 = 0, $4 = 0, $5 = 0.0, $6 = 0.0, $7 = 0.0, $vararg_buffer = 0, label = 0, sp = 0; | |
sp = STACKTOP; | |
STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abortStackOverflow(32|0); | |
$vararg_buffer = sp + 8|0; | |
$2 = 0; | |
$3 = $0; | |
$4 = $1; | |
$6 = --1.0; | |
$5 = $6; | |
$7 = $5; | |
HEAPF64[$vararg_buffer>>3] = $7; | |
(_printf(384,$vararg_buffer)|0); | |
STACKTOP = sp;return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment