ReadyTalk / avian

[INACTIVE] Avian is a lightweight virtual machine and class library designed to provide a useful subset of Java's features, suitable for building self-contained applications.
https://readytalk.github.io/avian/
Other
1.22k stars 173 forks source link

Unused variables breaking build #440

Closed io7m closed 9 years ago

io7m commented 9 years ago

Hello.

Using the default compiler (gcc (GCC) 5.1.0) on an up-to-date Arch Linux install, a plain make of 6ace3b655cf13dbd1e23b2535c51abf3305fea63 with no parameters results in:

compiling build/linux-x86_64/machine.o
In file included from src/avian/processor.h:18:0,
                 from src/avian/machine.h:21,
                 from src/avian/jnienv.h:14,
                 from src/machine.cpp:11:
src/avian/bootimage.h:64:17: error: ‘vm::TargetBootFlatConstant’ defined but not used [-Werror=unused-variable]
 #define NAME(x) Target##x
                 ^
src/bootimage-template.cpp:6:16: note: in expansion of macro ‘NAME’
 const unsigned NAME(BootFlatConstant) = 1 << NAME(BootShift);
                ^
src/avian/bootimage.h:64:17: error: ‘vm::TargetBootHeapOffset’ defined but not used [-Werror=unused-variable]
 #define NAME(x) Target##x
                 ^
src/bootimage-template.cpp:7:16: note: in expansion of macro ‘NAME’
 const unsigned NAME(BootHeapOffset) = 1 << (NAME(BootShift) + 1);
                ^
In file included from src/avian/processor.h:18:0,
                 from src/avian/machine.h:21,
                 from src/avian/jnienv.h:14,
                 from src/machine.cpp:11:
src/bootimage-template.cpp:6:21: error: ‘vm::BootFlatConstant’ defined but not used [-Werror=unused-variable]
 const unsigned NAME(BootFlatConstant) = 1 << NAME(BootShift);
                     ^
src/avian/bootimage.h:70:17: note: in definition of macro ‘NAME’
 #define NAME(x) x
                 ^
src/bootimage-template.cpp:7:21: error: ‘vm::BootHeapOffset’ defined but not used [-Werror=unused-variable]
 const unsigned NAME(BootHeapOffset) = 1 << (NAME(BootShift) + 1);
                     ^
src/avian/bootimage.h:70:17: note: in definition of macro ‘NAME’
 #define NAME(x) x
                 ^
cc1plus: all warnings being treated as errors
makefile:1804: recipe for target 'build/linux-x86_64/machine.o' failed
make: *** [build/linux-x86_64/machine.o] Error 1

I'm guessing this version of gcc produces more warnings than the developer(s) compilers, and the -Werror flag is causing issues here.

nartamonov commented 8 years ago

@joshuawarner32 @dicej There are troubles again :( In such case with MSYS2 and Avian v1.2.0:

In file included from src/avian/processor.h:18:0,
                 from src/avian/machine.h:21,
                 from src/avian/jnienv.h:14,
                 from src/machine.cpp:11:
src/avian/bootimage.h:64:17: error: 'vm::TargetBootFlatConstant' defined but not used [-Werror=unused-variable]
 #define NAME(x) Target##x
                 ^
src/bootimage-template.cpp:6:16: note: in expansion of macro 'NAME'
 const unsigned NAME(BootFlatConstant) = 1 << NAME(BootShift);
                ^
src/avian/bootimage.h:64:17: error: 'vm::TargetBootHeapOffset' defined but not used [-Werror=unused-variable]
 #define NAME(x) Target##x
                 ^
src/bootimage-template.cpp:7:16: note: in expansion of macro 'NAME'
 const unsigned NAME(BootHeapOffset) = 1 << (NAME(BootShift) + 1);
                ^
In file included from src/avian/processor.h:18:0,
                 from src/avian/machine.h:21,
                 from src/avian/jnienv.h:14,
                 from src/machine.cpp:11:
src/bootimage-template.cpp:6:21: error: 'vm::BootFlatConstant' defined but not used [-Werror=unused-variable]
 const unsigned NAME(BootFlatConstant) = 1 << NAME(BootShift);
                     ^
src/avian/bootimage.h:70:17: note: in definition of macro 'NAME'
 #define NAME(x) x
                 ^
src/bootimage-template.cpp:7:21: error: 'vm::BootHeapOffset' defined but not used [-Werror=unused-variable]
 const unsigned NAME(BootHeapOffset) = 1 << (NAME(BootShift) + 1);
                     ^
src/avian/bootimage.h:70:17: note: in definition of macro 'NAME'
 #define NAME(x) x
                 ^
cc1plus.exe: all warnings being treated as errors

May be it will be more convinient to turn off -Werror so that such errors could not happens anymore in the future?

io7m commented 8 years ago

I think turning off -Werror would be excessive; it's there for good reason, after all. Almost every warning turned off potentially hides a bug (-Wunused-variable in particular, for languages that have mutable variables ["Oops, I mutated the wrong thing and didn't notice"]).

nartamonov commented 8 years ago

Ah, I see. How about adding option suppress-warnings={true|false} to makefile? With default value = false. It will help to build avian in cases when uses compiler with stronger validation rules than developer's one (for example, in Arch linux). Because right now we (as users) are forced to manually patch makefile in order to build Avian.

io7m commented 8 years ago

To clarify, I don't speak for the developers. I do have an opinion on this matter though! :smile:

dicej commented 8 years ago

Yes, I can add an option to suppress the use of -Werror.

@nartamonov, what version of GCC are you using?

dicej commented 8 years ago

@nartamonov, I built Avian using the latest GCC (5.3.0) on Linux and got no warnings. Please try the latest Avian (from the GitHub master) and let me know if you still have problems.

nartamonov commented 8 years ago

@dicej, you're right! I use GCC 5.3.0 too and got no warnings on latest version from master. I got warnings only on latest release v1.2.0.

gcc version 5.3.0 (Rev2, Built by MSYS2 project)

Thanks for help!