summaryrefslogtreecommitdiff
path: root/miniany/libc-freestanding.c
diff options
context:
space:
mode:
Diffstat (limited to 'miniany/libc-freestanding.c')
-rw-r--r--miniany/libc-freestanding.c6
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 );
}