6 ms·
This code will not compile because we cannot return owner as non owner. To fix we need to add qualifier owner at return type. FILE* owner open_file(const
by thradams 3y ago
This code will not compile because we cannot return owner as non owner.
To fix we need to add qualifier owner at return type.
FILE* owner open_file(const char* p) {
FILE* owner f = …
return f;
}
Then when returning f , f is moved. Because f was moved the compiler will not complain at the end of scope of f.
https://thradams.com/cake/playground.html?code=I2luY2x1ZGUgPG93bmVyc2hpcC5oPiANCiNpbmNsdWRlIDxzdGRsaWIuaD4NCiNpbmNsdWRlIDxzdGRpby5oPg0KRklMRSAqIG93bmVyIG9wZW5maWxlKGNvbnN0IGNoYXIqIG5hbWUpDQp7DQogRklMRSAqb3duZXIgZiA9IGZvcGVuKCJmaWxlLnR4dCIsICJyIik7IA0KICByZXR1cm4gZjsNCn0NCg0KaW50IG1haW4oKQ0Kew0KICAgIEZJTEUgKm93bmVyIGYgPSBvcGVuZmlsZSgiZmlsZS50eHQiKTsgDQogICAgaWYgKGYpIGZjbG9zZShmKTsNCn0%3D&to=-1&options= https://thradams.com/cake/playground.html?code=I2luY2x1ZGUgP...