Open idea--list opened 4 years ago
Revisited the issue again. I find this code works:
#include "mbed.h"
#include <cstdio>
struct a_tag {
int i;
int n;
};
// return_struct: return a struct by value (copied)
struct a_tag return_struct(void) {
struct a_tag a; //create a temporary a_tag struct
a.i = 88;
a.n = 99;
return a;
}
int main()
{
struct a_tag myTag;
while (true) {
myTag = return_struct();
printf("integer: %d\tinteger: %d\n", myTag.i, myTag.n);
ThisThread::sleep_for(1000ms);
}
}
So it seems the issue is only introduced if the struct contains character or string.
Still the same with Mbed OS 6.15 regardless of compiler (ARMC6.16 or GCC_ARM 10.3-2021.07), no improvement with recent releases.
Description of defect
When using functions that return struct the Artemis Thing Plus throws the following error message:
The same code runs without any errors on my MAX32630FTHR
Target(s) affected by this defect ?
Artemis Thing Plus (and i guess all the other artemis boards might be affected too)
Toolchain(s) (name and version) displaying this defect ?
ARMC 6.14
What version of Mbed-os are you using (tag or sha) ?
Mbed OS V6.3
What version(s) of tools are you using. List all that apply (E.g. mbed-cli)
Mbed Studio V1.3.0
How is this defect reproduced ?
Compile&flash this code: