Skip to content

Instantly share code, notes, and snippets.

@TannerRogalsky
Created February 11, 2018 00:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TannerRogalsky/7fc22007b55a9a2f15a845b5a694d69a to your computer and use it in GitHub Desktop.
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.
#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;
}
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