ryanqq / openjpeg

Automatically exported from code.google.com/p/openjpeg
Other
0 stars 0 forks source link

warning: cast from 'OPJ_BYTE *' (aka 'unsigned char *') to 'OPJ_INT32 *' (aka 'int *') increases required alignment from 1 to 4 [-Wcast-align] #255

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Download r2369
2.
CXX=/usr/bin/c++  
CXXFLAGS="-stdlib=libstdc++ -std=c++03   -Wall -Wcast-align 
-Wdisabled-optimization -Wextra -Wformat=2 -Winvalid-pch -Wno-format-nonliteral 
-Wpointer-arith -Wunused -Wwrite-strings -funit-at-a-time -Wno-strict-overflow 
-Wno-deprecated -Wno-invalid-offsetof -Woverloaded-virtual"
CC=/usr/bin/cc
CFLAGS="-Wno-uninitialized -Wno-unused-parameter -Wall -Wcast-align 
-Wdisabled-optimization -Wextra -Wformat=2 -Winvalid-pch -Wno-format-nonliteral 
-Wpointer-arith -Wunused -Wwrite-strings -funit-at-a-time -Wno-strict-overflow"
3. Configure & Compile

What is the expected output? What do you see instead?
Expected to get compilation with no warnings or errors.

38  compiler warnings issued

What version of the product are you using? On what operating system?

r2369

Please provide any additional information below.

[  2%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/j2k.c.o
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:1616:44: warning: unused parameter 'p_j2k'
      [-Wunused-parameter]
OPJ_BOOL opj_j2k_calculate_tp(  opj_j2k_t *p_j2k,
                                           ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:1620:75: warning: unused parameter 'p_manager'
      [-Wunused-parameter]
                                                        opj_event_mgr_t * p_manager
                                                                          ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:2253:48: warning: unused parameter 'p_j2k'
      [-Wunused-parameter]
static OPJ_BOOL opj_j2k_read_com (  opj_j2k_t *p_j2k,
                                               ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:2254:48: warning: unused parameter
      'p_header_data' [-Wunused-parameter]
                                    OPJ_BYTE * p_header_data,
                                               ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:2256:55: warning: unused parameter 'p_manager'
      [-Wunused-parameter]
                                    opj_event_mgr_t * p_manager
                                                      ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:2927:83: warning: unused parameter 'p_manager'
      [-Wunused-parameter]
                                                                opj_event_mgr_t * p_manager
                                                                                  ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:3152:48: warning: unused parameter
      'p_header_data' [-Wunused-parameter]
                                    OPJ_BYTE * p_header_data,
                                               ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:3191:48: warning: unused parameter 'p_j2k'
      [-Wunused-parameter]
static OPJ_BOOL opj_j2k_read_tlm (  opj_j2k_t *p_j2k,
                                               ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:3247:48: warning: unused parameter 'p_j2k'
      [-Wunused-parameter]
static OPJ_BOOL opj_j2k_read_plm (  opj_j2k_t *p_j2k,
                                               ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:3248:48: warning: unused parameter
      'p_header_data' [-Wunused-parameter]
                                    OPJ_BYTE * p_header_data,
                                               ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:3317:48: warning: unused parameter 'p_j2k'
      [-Wunused-parameter]
static OPJ_BOOL opj_j2k_read_plt (  opj_j2k_t *p_j2k,
                                               ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:3823:85: warning: unused parameter 'p_stream'
      [-Wunused-parameter]
                                                        const opj_stream_private_t *p_stream,
                                                                                    ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:3824:75: warning: unused parameter 'p_manager'
      [-Wunused-parameter]
                                                        opj_event_mgr_t * p_manager
                                                                          ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:4115:85: warning: unused parameter 'p_stream'
      [-Wunused-parameter]
                                                        const opj_stream_private_t *p_stream,
                                                                                    ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:4471:79: warning: unused parameter 'p_manager'
      [-Wunused-parameter]
                                                            opj_event_mgr_t * p_manager )
                                                                              ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:4632:79: warning: unused parameter 'p_stream'
      [-Wunused-parameter]
                                                        opj_stream_private_t *p_stream,
                                                                              ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:4682:80: warning: unused parameter 'p_manager'
      [-Wunused-parameter]
                                                        struct opj_event_mgr * p_manager )
                                                                               ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:4815:72: warning: unused parameter 'p_manager'
      [-Wunused-parameter]
                                                struct opj_event_mgr * p_manager )
                                                                       ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:5972:46: warning: cast from 'OPJ_BYTE *'
      (aka 'unsigned char *') to 'OPJ_INT32 *' (aka 'int *') increases required alignment from 1 to 4 [-Wcast-align]
                    OPJ_INT32 * l_dc_shift = (OPJ_INT32 *) ((OPJ_BYTE *) parameters->mct_data + lMctSize);
                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:6243:87: warning: unused parameter 'p_stream'
      [-Wunused-parameter]
                                                                opj_stream_private_t *p_stream,
                                                                                      ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:6244:83: warning: unused parameter 'p_manager'
      [-Wunused-parameter]
                                                                opj_event_mgr_t * p_manager )
                                                                                  ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:6453:99: warning: unused parameter 'p_stream'
      [-Wunused-parameter]
                                                                            opj_stream_private_t *p_stream,
                                                                                                  ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:6488:63: warning: unused parameter 'p_stream'
      [-Wunused-parameter]
                                        opj_stream_private_t *p_stream,
                                                              ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:6489:59: warning: unused parameter 'p_manager'
      [-Wunused-parameter]
                                        opj_event_mgr_t * p_manager
                                                          ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:6676:83: warning: unused parameter 'p_stream'
      [-Wunused-parameter]
                                                            opj_stream_private_t *p_stream,
                                                                                  ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:7525:65: warning: cast from 'OPJ_BYTE *'
      (aka 'unsigned char *') to 'OPJ_INT16 *' (aka 'short *') increases required alignment from 1 to 2 [-Wcast-align]
                                        OPJ_INT16 * l_src_ptr = (OPJ_INT16 *) p_data;
                                                                ^~~~~~~~~~~~~~~~~~~~
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:7555:65: warning: cast from 'OPJ_BYTE *'
      (aka 'unsigned char *') to 'OPJ_INT32 *' (aka 'int *') increases required alignment from 1 to 4 [-Wcast-align]
                                        OPJ_INT32 * l_src_ptr = (OPJ_INT32 *) p_data;
                                                                ^~~~~~~~~~~~~~~~~~~~
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:9294:66: warning: cast from 'OPJ_BYTE *'
      (aka 'unsigned char *') to 'OPJ_INT16 *' (aka 'short *') increases required alignment from 1 to 2 [-Wcast-align]
                                        OPJ_INT16 * l_dest_ptr = (OPJ_INT16 *) p_data;
                                                                 ^~~~~~~~~~~~~~~~~~~~
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:9317:66: warning: cast from 'OPJ_BYTE *'
      (aka 'unsigned char *') to 'OPJ_INT32 *' (aka 'int *') increases required alignment from 1 to 4 [-Wcast-align]
                                        OPJ_INT32 * l_dest_ptr = (OPJ_INT32 *) p_data;
                                                                 ^~~~~~~~~~~~~~~~~~~~
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:9681:84: warning: unused parameter 'p_stream'
      [-Wunused-parameter]
                                                        struct opj_stream_private *p_stream,
                                                                                   ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:9682:80: warning: unused parameter 'p_manager'
      [-Wunused-parameter]
                                                        struct opj_event_mgr * p_manager )
                                                                               ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:9712:71: warning: unused parameter 'p_stream'
      [-Wunused-parameter]
                                                opj_stream_private_t *p_stream,
                                                                      ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:9713:67: warning: unused parameter 'p_manager'
      [-Wunused-parameter]
                                                opj_event_mgr_t * p_manager
                                                                  ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:9732:76: warning: unused parameter 'p_stream'
      [-Wunused-parameter]
                                                struct opj_stream_private *p_stream,
                                                                           ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:9793:91: warning: unused parameter 'p_stream'
      [-Wunused-parameter]
                                                                    opj_stream_private_t *p_stream,
                                                                                          ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:4631:10: warning: unused function
      'opj_j2k_read_eoc' [-Wunused-function]
OPJ_BOOL opj_j2k_read_eoc (     opj_j2k_t *p_j2k,
         ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:4742:10: warning: unused function
      'opj_j2k_write_all_coc' [-Wunused-function]
OPJ_BOOL opj_j2k_write_all_coc(opj_j2k_t *p_j2k,
         ^
/Users/johnsonhj/src/NAMICExternalProjects/SuperBuild/ExternalSources/OpenJPEG/s
rc/lib/openjp2/j2k.c:4763:10: warning: unused function
      'opj_j2k_write_all_qcc' [-Wunused-function]
OPJ_BOOL opj_j2k_write_all_qcc(opj_j2k_t *p_j2k,
         ^
38 warnings generated.

Original issue reported on code.google.com by hans.j.j...@gmail.com on 2 Feb 2014 at 6:29

GoogleCodeExporter commented 9 years ago

Original comment by mathieu.malaterre on 21 Feb 2014 at 9:14

GoogleCodeExporter commented 9 years ago
ctest scripts was updated, see ks200451-trunk-nightly-debug-linux_clang.ctest

Original comment by mathieu.malaterre on 25 Feb 2014 at 4:58

GoogleCodeExporter commented 9 years ago
I do not think those can cause any harm at all:

     (aka 'unsigned char *') to 'OPJ_INT16 *' (aka 'short *') increases required alignment from 1 to 2 [-Wcast-align]
                                        OPJ_INT16 * l_src_ptr = (OPJ_INT16 *) p_data;

who is using sparc anyway ?

Original comment by mathieu.malaterre on 14 Mar 2014 at 4:49

GoogleCodeExporter commented 9 years ago

Original comment by mathieu.malaterre on 14 Mar 2014 at 4:49

GoogleCodeExporter commented 9 years ago
Summary was too vague.

Original comment by mathieu.malaterre on 17 Mar 2014 at 10:19

GoogleCodeExporter commented 9 years ago
Suggested fix is to use union:

http://stackoverflow.com/questions/2741787/warning-cast-increases-required-align
ment

Original comment by mathieu.malaterre on 17 Mar 2014 at 10:19

GoogleCodeExporter commented 9 years ago
Just for reference, this does not impact x86

Original comment by mathieu.malaterre on 17 Mar 2014 at 10:22

GoogleCodeExporter commented 9 years ago

Original comment by mathieu.malaterre on 18 Mar 2014 at 2:48