diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2021-09-01 19:40:45 +0000 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2021-09-01 19:40:45 +0000 |
commit | 660a0c3c89090548ff9ea5802eb3325dc1432727 (patch) | |
tree | c3ffca49eae09b0978295119cdcc17c30dcd889b | |
parent | d03ca0906302aebf0dd6d9f9517d154f7b3e6fe4 (diff) | |
download | compilertests-660a0c3c89090548ff9ea5802eb3325dc1432727.tar.gz compilertests-660a0c3c89090548ff9ea5802eb3325dc1432727.tar.bz2 |
loosing time in freestanding gcc-opimized code with volatile string buffers on the stack (aka fun)
-rw-r--r-- | miniany/libc-freestanding.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/miniany/libc-freestanding.c b/miniany/libc-freestanding.c index 09d9fc8..31808e7 100644 --- a/miniany/libc-freestanding.c +++ b/miniany/libc-freestanding.c @@ -132,7 +132,11 @@ enum { static void print_char( int fd, int c ) { - char s[1]; + /* gcc 10 and 11 think on -O1 and -O2 that s can be held in registers, thus + * clobbering the output? Let's put a volatile here seems to help. Neither + * clang nor tcc show this behaviour.. + */ + volatile char s[1]; s[0] = c; syscall3( SYSCALL_WRITE, fd, (int)s, 1 ); } |