sunflower-embedded-system-emulator
sunflower-embedded-system-emulator copied to clipboard
Compiler warnings on gcc
Describe the bug There are some compiler warnings left when compiling on my system (gcc, see log for version information).
To Reproduce Steps to reproduce the behavior:
- Change SUNFLOWERROOT
- Compile
make clean
make
Expected behavior No warnings, as on clang.
Host OS (please complete the following information):
- OS: Arch Linux
- Version git revision
b912d0a7e85f6cb914be941d2278e286c68a4c35
You local changes (please complete the following information):
- Output of
git diff. From root:
diff --git a/sunflower-toolchain b/sunflower-toolchain
--- a/sunflower-toolchain
+++ b/sunflower-toolchain
@@ -1 +1 @@
-Subproject commit e05d96d3da7b9cdb54b3f6895545771fb9935e90
+Subproject commit e05d96d3da7b9cdb54b3f6895545771fb9935e90-dirty
From sunflower-toolchain:
diff --git a/conf/setup.conf b/conf/setup.conf
index cb2a51b..4a863d2 100755
--- a/conf/setup.conf
+++ b/conf/setup.conf
@@ -1,7 +1,7 @@
##
## You will want to change the following to suit your setup:
##
-SUNFLOWERROOT = /tmp/sunflower-simulator
+SUNFLOWERROOT = /home/arch/git/sunflower-simulator
OSTYPE = linux
MACHTYPE = i386
- Output of
git remote -v.
origin https://github.com/physical-computation/sunflower-simulator.git (fetch)
origin https://github.com/physical-computation/sunflower-simulator.git (push)
Additional context Terminal log including gcc version and flags.
Terminal log (click to expand)
Terminal line:
~/git/sunflower-simulator make clean
Output:
make[1]: Entering directory '/home/arch/git/sunflower-simulator/sim'
/bin/rm -f sf *.o *.core core *.tab.c mversion.h help.h commands.tex opstr-*.h decode-riscv.h decode-hitachi-sh.h parsedriver.i lex.i *.output gmon.out sunflower.out
make[1]: Leaving directory '/home/arch/git/sunflower-simulator/sim'
Terminal line:
~/git/sunflower-simulator make
Output:
make[1]: Entering directory '/home/arch/git/sunflower-simulator/sim'
./mkdecode-hitachi-sh gawk > decode-hitachi-sh.h
./mkdecode-riscv gawk > decode-riscv.h
./mkhelp gawk > help.h
echo 'char const MVERSION[] = "1.1 (build '`date '+%m-%d-%Y-%H:%M:%S'`-`whoami`@`hostname`-`uname`\)\"\; > mversion.h
./mkopstr-hitachi-sh gawk > opstr-hitachi-sh.h
./mkopstr-riscv gawk > opstr-riscv.h
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c randgen.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c arch-linux.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c batt.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c bit-utils.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c decode-hitachi-sh.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c decode-riscv.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c dev7708.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c devsim7708.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c fault.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c fdr.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c machine-hitachi-sh.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c machine-riscv.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c inst_uncertain.c
inst_uncertain.c: In function ‘print_register_row’:
inst_uncertain.c:587:49: warning: ‘%-*d’ directive output truncated writing between 5 and 11 bytes into a region of size 4 [-Wformat-truncation=]
587 | result = snprintf(buffer, PRINT_DIGITS + 1, " u%-*d", PRINT_DIGITS, row);
| ^~~~
inst_uncertain.c:587:11: note: ‘snprintf’ output between 8 and 14 bytes into a destination of size 6
587 | result = snprintf(buffer, PRINT_DIGITS + 1, " u%-*d", PRINT_DIGITS, row);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c main.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c merror.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c mmalloc.c
mmalloc.c: In function ‘mmalloc’:
mmalloc.c:161:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
161 | Maddr addr = (Maddr)malloc(size);
| ^
mmalloc.c:167:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
167 | return (void *)addr;
| ^
mmalloc.c: In function ‘mcalloc’:
mmalloc.c:173:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
173 | Maddr addr = (Maddr)calloc(nelem, size);
| ^
mmalloc.c:179:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
179 | return (void *)addr;
| ^
mmalloc.c: In function ‘mrealloc’:
mmalloc.c:185:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
185 | Maddr addr = (Maddr)realloc(oldptr, size);
| ^
mmalloc.c:191:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
191 | return (void *)addr;
| ^
mmalloc.c: In function ‘mfree’:
mmalloc.c:212:36: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
212 | if (E->memblocks[i].addrs[j] == (Maddr)ptr)
| ^
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c mmu-hitachi-sh.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c network-hitachi-sh.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c op-hitachi-sh.c -o op-hitachi-sh.o
In file included from op-hitachi-sh.c:79:
memory-hierarchy.c: In function ‘superHwritebyte’:
memory-hierarchy.c:240:17: warning: variable ‘destbase’ set but not used [-Wunused-but-set-variable]
240 | ulong offset, destbase, destoffset;
| ^~~~~~~~
memory-hierarchy.c: In function ‘superHwriteword’:
memory-hierarchy.c:526:33: warning: variable ‘destbase’ set but not used [-Wunused-but-set-variable]
526 | ulong offset, destoffset = 0, destbase;
| ^~~~~~~~
memory-hierarchy.c: In function ‘superHwritelong’:
memory-hierarchy.c:836:33: warning: variable ‘destbase’ set but not used [-Wunused-but-set-variable]
836 | ulong offset, destoffset = 0, destbase;
| ^~~~~~~~
memory-hierarchy.c: In function ‘superHreadbyte’:
memory-hierarchy.c:1155:33: warning: variable ‘destbase’ set but not used [-Wunused-but-set-variable]
1155 | ulong offset, destoffset = 0, destbase;
| ^~~~~~~~
memory-hierarchy.c: In function ‘superHreadword’:
memory-hierarchy.c:1426:33: warning: variable ‘destbase’ set but not used [-Wunused-but-set-variable]
1426 | ulong offset, destoffset = 0, destbase;
| ^~~~~~~~
memory-hierarchy.c: In function ‘superHreadlong’:
memory-hierarchy.c:1719:33: warning: variable ‘destbase’ set but not used [-Wunused-but-set-variable]
1719 | ulong offset, destoffset = 0, destbase;
| ^~~~~~~~
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c op-riscv.c -o op-riscv.o
op-riscv.c: In function ‘rv32f_fmin_s’:
op-riscv.c:1340:46: warning: overflow in conversion from ‘double’ to ‘int’ changes value from ‘+QNaN’ to ‘0’ [-Woverflow]
1340 | uncertain_inst_mv(S->riscv->uncertain, rd, nan(""));
| ^~~~~~~
op-riscv.c: In function ‘rv32f_fmax_s’:
op-riscv.c:1375:46: warning: overflow in conversion from ‘double’ to ‘int’ changes value from ‘+QNaN’ to ‘0’ [-Woverflow]
1375 | uncertain_inst_mv(S->riscv->uncertain, rd, nan(""));
| ^~~~~~~
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c pau.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c physics.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c mass.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c propulsion.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c pic.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c pipeline-hitachi-sh.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c pipeline-riscv.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c power.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c regaccess-riscv.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c syscalls.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c tokenhandling.c
bison -t -v -Wno-other -Wno-conflicts-sr -Wno-conflicts-rr -p sf_superh_ sf-hitachi-sh.y
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c sf-hitachi-sh.tab.c -o sf-hitachi-sh.o
bison -t -v -Wno-other -Wno-conflicts-sr -Wno-conflicts-rr -p sf_riscv_ sf-riscv.y
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c sf-riscv.tab.c -o sf-riscv.o
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c taint.c
gcc -g -DSF_L_ENDIAN -Wall -g -m32 -O0 -c uncertain-histogram.c
./mkmantex gawk > commands.tex
gcc -g randgen.o arch-linux.o batt.o bit-utils.o decode-hitachi-sh.o decode-riscv.o dev7708.o devsim7708.o fault.o fdr.o machine-hitachi-sh.o machine-riscv.o inst_uncertain.o main.o merror.o mmalloc.o mmu-hitachi-sh.o network-hitachi-sh.o op-hitachi-sh.o op-riscv.o pau.o physics.o mass.o propulsion.o pic.o pipeline-hitachi-sh.o pipeline-riscv.o power.o regaccess-riscv.o syscalls.o tokenhandling.o sf-hitachi-sh.o sf-riscv.o taint.o uncertain-histogram.o -m32 -lm -lpthread -o sf
make[1]: Leaving directory '/home/arch/git/sunflower-simulator/sim'
Terminal line:
~/git/sunflower-simulator gcc -v
Output:
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib --disable-werror --enable-checking=release --enable-default-pie --enable-default-ssp --enable-cet=auto
Thread model: posix
gcc version 9.2.0 (GCC)
Terminal line:
~/git/sunflower-simulator git rev-parse HEAD
Output:
b912d0a7e85f6cb914be941d2278e286c68a4c35
See https://github.com/physical-computation/sunflower-simulator/issues/69
Fixed in #149.