Avoid possible simplified lowering of passed struct (#2938)
This commit is contained in:
@ -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);
|
|
||||||
|
static struct test_struct __attribute__ ((noinline)) test_function(void) {
|
||||||
|
struct test_struct s;
|
||||||
|
s.x = 3;
|
||||||
|
s.y = 4;
|
||||||
|
s.z = 5;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
extern bool entrypoint(const uint8_t* input) {
|
extern bool entrypoint(const uint8_t* input) {
|
||||||
struct foo foo = bar(input);
|
struct test_struct s = test_function();
|
||||||
sol_log_64(0, 0, 0, (uint64_t)input, (uint64_t)foo.input);
|
sol_log("foobar");
|
||||||
sol_assert(input == foo.input);
|
if (s.x + s.y + s.z == 12 ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
struct foo bar(const uint8_t *input) {
|
|
||||||
struct foo foo;
|
|
||||||
foo.input = input;
|
|
||||||
return foo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user