Home » U++ Library support » U++ Core » clamp() function crashes apps on Linux, gets warning from GCC and CLANG
clamp() function crashes apps on Linux, gets warning from GCC and CLANG [message #54576] |
Sat, 15 August 2020 23:10 |
Oblivion
Messages: 1093 Registered: August 2007
|
Senior Contributor |
|
|
Hi,
clamp function in the latest SVN build (rev. 14827) crashes apps.
GCC and CLANG complains about a reference to local variable addr.
Example:
#include <Core/Core.h>
using namespace Upp;
Size fn1()
{
Size sz1(Random(100), Random(100));
Size sz2(Random(1000), Random(1000));
Size sz3(Random(1000), Random(1000));
return clamp(sz1, sz2, sz3);
}
Size fn2()
{
Size sz1(Random(100), Random(100));
Size sz2(Random(1000), Random(1000));
Size sz3(Random(1000), Random(1000));
return min(max(sz1, sz2), sz3);
}
CONSOLE_APP_MAIN
{
// both GCC and CLANG warns about reference to local-addr.
Size sz1 = fn1(); // Crashes the app with invalid memory access.
DUMP(sz1);
Size sz2 = fn2(); // Does not crash.
DUMP(sz2);
}
Best regards,
Oblivion
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Sat, 15 August 2020 23:29] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sat May 11 12:17:13 CEST 2024
Total time taken to generate the page: 0.01739 seconds
|