vovkos / jancy_b

This is a repository bundle (Jancy + Graco + AXL). With this bundle you can conveniently build Jancy and all the libraries and tools it depends on -- in correct order and from the single source tree.
MIT License
1 stars 0 forks source link

Several compiler warnings #1

Open mingodad opened 3 years ago

mingodad commented 3 years ago

Adding -Wall -Wextra compiler flags there is a lot of noise warnings:

1 - Instead of setting/comparing size_t == -1 why not define a macro #define SIZE_ERROR MAX_SIZE and use it to remove lots of noise warnings ?

2 - Replace struct partial initiialization like timespec timespec = {0}; by timespec timespec = {}; also remove several noise warnings.

3 - Remove the parameter names for function declarations that don't use then (QtCaret::timerEvent (QTimerEvent* /*e*/)) also remove a lot of noise warnings.

4 - Several others like the above.

Then we can start seeing helpful compiler warnings like:

Building CXX object axl/src/axl_core/CMakeFiles/axl_core.dir/axl_err_Error.cpp.o
In file included from /home/mingo/dev/c/A_programming-languages/jancy_b/axl/src/axl_core/axl_err_Error.cpp:14:
In file included from /home/mingo/dev/c/A_programming-languages/jancy_b/axl/include/axl_err_ErrorMgr.h:1:
In file included from /home/mingo/dev/c/A_programming-languages/jancy_b/axl/include/axl_err/axl_err_ErrorMgr.h:17:
In file included from /home/mingo/dev/c/A_programming-languages/jancy_b/axl/include/axl_sl_HashTable.h:1:
In file included from /home/mingo/dev/c/A_programming-languages/jancy_b/axl/include/axl_sl/axl_sl_HashTable.h:21:
/home/mingo/dev/c/A_programming-languages/jancy_b/axl/include/axl_sl/axl_sl_Singleton.h:38:3: warning: destructor called on non-final 'axl::err::ErrorMgr' that has virtual functions but non-virtual destructor [-Wdelete-non-abstract-non-virtual-dtor]
                m_p->~T();
                ^
/home/mingo/dev/c/A_programming-languages/jancy_b/axl/include/axl_sl/axl_sl_Singleton.h:55:45: note: in instantiation of member function 'axl::sl::DestructSingleton<axl::err::ErrorMgr>::finalize' requested here
                ref::Ptr<Destruct> destruct = AXL_REF_NEW(Destruct);
                                                          ^
/home/mingo/dev/c/A_programming-languages/jancy_b/axl/include/axl_sl/axl_sl_CallOnce.h:52:3: note: in instantiation of member function 'axl::sl::ConstructSingleton<axl::err::ErrorMgr>::operator()' requested here
                functor(argument);
                ^
/home/mingo/dev/c/A_programming-languages/jancy_b/axl/include/axl_sl/axl_sl_Singleton.h:68:2: note: in instantiation of function template specialization 'axl::sl::callOnce<axl::sl::ConstructSingleton<axl::err::ErrorMgr>, unsigned char *>' requested here
        callOnce(ConstructSingleton<T> (), buffer, flag);
        ^
/home/mingo/dev/c/A_programming-languages/jancy_b/axl/include/axl_err/axl_err_ErrorMgr.h:117:13: note: in instantiation of function template specialization 'axl::sl::getSingleton<axl::err::ErrorMgr>' requested here
        return sl::getSingleton<ErrorMgr> ();
                   ^
/home/mingo/dev/c/A_programming-languages/jancy_b/axl/include/axl_sl/axl_sl_Singleton.h:38:9: note: qualify call to silence this warning
                m_p->~T();
                      ^
                      axl::err::ErrorMgr::
...
In file included from /home/mingo/dev/c/A_programming-languages/jancy_b/axl/src/axl_gui/axl_gui_HyperText.cpp:15:
In file included from /home/mingo/dev/c/A_programming-languages/jancy_b/axl/include/axl_gui_Widget.h:1:
/home/mingo/dev/c/A_programming-languages/jancy_b/axl/include/axl_gui/axl_gui_Widget.h:187:10: warning: unused parameter 'pos' [-Wunused-parameter]
                size_t pos = 0
...
/home/mingo/dev/c/A_programming-languages/jancy_b/axl/src/axl_gui/axl_gui_HyperText.cpp:227:9: warning: unused variable 'length' [-Wunused-variable]
        size_t length = m_text.getLength();
               ^
...
/home/mingo/dev/c/A_programming-languages/jancy_b/axl/src/axl_fsm/axl_fsm_Regex.cpp:164:25: warning: format specifies type 'int' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
                        printf("open (%d) ", nfaState->m_captureId);
                                      ~~     ^~~~~~~~~~~~~~~~~~~~~
                                      %zu
/home/mingo/dev/c/A_programming-languages/jancy_b/axl/src/axl_fsm/axl_fsm_Regex.cpp:167:26: warning: format specifies type 'int' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
                        printf("close (%d) ", nfaState->m_captureId);
                                       ~~     ^~~~~~~~~~~~~~~~~~~~~
                                       %zu
/home/mingo/dev/c/A_programming-languages/jancy_b/axl/src/axl_fsm/axl_fsm_Regex.cpp:215:19: warning: format specifies type 'int' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
                                printf("%d ", i);
                                        ~~    ^
                                        %zu
/home/mingo/dev/c/A_programming-languages/jancy_b/axl/src/axl_fsm/axl_fsm_Regex.cpp:229:19: warning: format specifies type 'int' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
                                printf("%d ", i);
                                        ~~    ^
                                        %zu
...
mingodad commented 3 years ago

Also:

/home/mingo/dev/c/A_programming-languages/jancy_b/graco/src/Parser.cpp:362:10: warning: implicit conversion of NULL constant to 'bool' [-Wnull-conversion]
                return NULL;
                ~~~~~~ ^~~~
                       false
/home/mingo/dev/c/A_programming-languages/jancy_b/graco/src/Parser.cpp:368:10: warning: implicit conversion of NULL constant to 'bool' [-Wnull-conversion]
                return NULL;
                ~~~~~~ ^~~~
                       false
/home/mingo/dev/c/A_programming-languages/jancy_b/graco/src/Parser.cpp:384:10: warning: implicit conversion of NULL constant to 'bool' [-Wnull-conversion]
                return NULL;
                ~~~~~~ ^~~~
                       false
...
/home/mingo/dev/c/A_programming-languages/jancy_b/jancy/src/jnc_ct/jnc_ct_OperatorMgr/jnc_ct_OperatorMgr_Closure.cpp:125:10: warning: implicit conversion of NULL constant to 'bool' [-Wnull-conversion]
                return NULL;
                ~~~~~~ ^~~~
                       false
vovkos commented 3 years ago

Also:

/home/mingo/dev/c/A_programming-languages/jancy_b/graco/src/Parser.cpp:362:10: warning: implicit conversion of NULL constant to 'bool' [-Wnull-conversion] return NULL;


                       false
/home/mingo/dev/c/A_programming-languages/jancy_b/graco/src/Parser.cpp:368:10: warning: implicit conversion of NULL constant to 'bool' [-Wnull-conversion]
                return NULL;
                ~~~~~~ ^~~~
                       false
/home/mingo/dev/c/A_programming-languages/jancy_b/graco/src/Parser.cpp:384:10: warning: implicit conversion of NULL constant to 'bool' [-Wnull-conversion]
                return NULL;
                ~~~~~~ ^~~~
                       false
...
/home/mingo/dev/c/A_programming-languages/jancy_b/jancy/src/jnc_ct/jnc_ct_OperatorMgr/jnc_ct_OperatorMgr_Closure.cpp:125:10: warning: implicit conversion of NULL constant to 'bool' [-Wnull-conversion]
                return NULL;
                ~~~~~~ ^~~~
                       false

These are the duplicates of the previously fixed warnings. Pull the latest jancy_b and these should be gone.

vovkos commented 3 years ago

Regarding warning fixes -- I agree, "deep" warnings help to clean up certain bugs. However, could you elaborate on this one:

2 - Replace struct partial initiialization like timespec timespec = {0}; by timespec timespec = {}; also remove several noise warnings.

Not quite sure which warning it might cause?

Thing is, = {} is less compatible than = {0} (for example, MSVC has issues with it), so I would prefer to keep zero-initializers to remain in form of = {0} and maybe fix the particular warnings in some other way...

mingodad commented 3 years ago

Probably in cases like the one you mention using a macro that can be set to a value that eliminate the warning for other compilers, something like:

#ifdef _MSC_
#define STINIT 0
#else
#define STINIT
#endif

SomeStruct ss = {STINIT};