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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 11 deletions

View File

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