Avoid possible simplified lowering of passed struct (#2938)

This commit is contained in:
Jack May
2019-02-25 17:05:59 -08:00
committed by GitHub
parent 2f44555437
commit ba5077701d

View File

@ -1,18 +1,21 @@
#include <solana_sdk.h> #include <solana_sdk.h>
struct foo {const uint8_t *input;}; struct test_struct { uint64_t x; uint64_t y; uint64_t z;};
struct foo bar(const uint8_t *input);
extern bool entrypoint(const uint8_t *input) { static struct test_struct __attribute__ ((noinline)) test_function(void) {
struct foo foo = bar(input); struct test_struct s;
sol_log_64(0, 0, 0, (uint64_t)input, (uint64_t)foo.input); s.x = 3;
sol_assert(input == foo.input); s.y = 4;
return true; s.z = 5;
return s;
} }
struct foo bar(const uint8_t *input) { extern bool entrypoint(const uint8_t* input) {
struct foo foo; struct test_struct s = test_function();
foo.input = input; sol_log("foobar");
return foo; if (s.x + s.y + s.z == 12 ) {
return true;
}
return false;
} }