Opened 8 years ago

Closed 5 years ago

#6218 closed defect (wontfix)

What from clang's -Weverything can we use?

Reported by: Kurt Schwehr Owned by: warmerdam
Priority: normal Milestone: closed_because_of_github_migration
Component: default Version: svn-trunk
Severity: minor Keywords:
Cc:

Description

I think these are worth aiming for:

  • -Wold-style-cast
  • -Wshorten-64-to-32

Less likely:

  • -Wreserved-id-macro

Mac with xcode 7:

clang --version
Apple LLVM version 7.0.0 (clang-700.0.72)

gives for example

In file included from /Users/schwehr/src/gdal/gdal/port/cpl_error.h:34:
/Users/schwehr/src/gdal/gdal/port/cpl_port.h:226:9: error: 'long long' is a C++11 extension [-Werror,-Wc++11-long-long]
typedef long long        GIntBig;
        ^
/Users/schwehr/src/gdal/gdal/port/cpl_port.h:227:18: error: 'long long' is a C++11 extension [-Werror,-Wc++11-long-long]
typedef unsigned long long GUIntBig;
                 ^
In file included from cpl_error.cpp:32:
/Users/schwehr/src/gdal/gdal/port/cpl_error.h:41:4: error: unknown command tag name [-Werror,-Wdocumentation-unknown-command]
 * \file cpl_error.h
   ^
In file included from cpl_error.cpp:33:
/Users/schwehr/src/gdal/gdal/port/cpl_string.h:33:9: error: macro name is a reserved identifier [-Werror,-Wreserved-id-macro]
#define _CPL_STRING_H_INCLUDED
        ^
/Users/schwehr/src/gdal/gdal/port/cpl_string.h:358:50: error: use of old-style cast [-Werror,-Wold-style-cast]
    char * operator[](size_t i) { return (*this)[(int)i]; }
                                                 ^    ~
/Users/schwehr/src/gdal/gdal/port/cpl_string.h:360:62: error: use of old-style cast [-Werror,-Wold-style-cast]
    const char * operator[](size_t i) const { return (*this)[(int)i]; }
                                                             ^    ~
In file included from cpl_error.cpp:36:
/Users/schwehr/src/gdal/gdal/port/cpl_multiproc.h:32:9: error: macro name is a reserved identifier [-Werror,-Wreserved-id-macro]
#define _CPL_MULTIPROC_H_INCLUDED_
        ^
cpl_error.cpp:41:69: error: extra ';' outside of a function is a C++11 extension [-Werror,-Wc++11-extra-semi]
CPL_CVSID("$Id: cpl_error.cpp 31445 2015-11-12 06:41:38Z goatbar $");
                                                                    ^
cpl_error.cpp:62:9: error: padding size of 'CPLErrorContext' with 4 bytes to alignment boundary [-Werror,-Wpadded]
typedef struct {
        ^
cpl_error.cpp:281:46: error: implicit conversion changes signedness: 'int' to 'unsigned long' [-Werror,-Wsign-conversion]
                                    + psCtx->nLastErrMsgMax + 1));
                                    ~ ~~~~~~~^~~~~~~~~~~~~~
cpl_error.cpp:293:43: error: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Werror,-Wsign-conversion]
                     psCtx->nLastErrMsgMax-nPreviousSize, fmt, wrk_args )) == -1
                     ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
cpl_error.cpp:308:38: error: implicit conversion changes signedness: 'int' to 'unsigned long' [-Werror,-Wsign-conversion]
                            + psCtx->nLastErrMsgMax + 1) );
                            ~ ~~~~~~~^~~~~~~~~~~~~~
cpl_error.cpp:271:29: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int'
      [-Werror,-Wshorten-64-to-32]
            nPreviousSize = strlen(psCtx->szLastErrMsg);
                          ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~
cpl_error.cpp:666:49: error: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Werror,-Wsign-conversion]
    strncpy(psCtx->szLastErrMsg, pszMsg, psCtx->nLastErrMsgMax);
    ~~~~~~~                              ~~~~~~~^~~~~~~~~~~~~~
cpl_error.cpp:1067:14: error: use of old-style cast [-Werror,-Wold-style-cast]
    psNode = (CPLErrorHandlerNode *) CPLMalloc(sizeof(CPLErrorHandlerNode));
             ^                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Change History (6)

comment:1 by Even Rouault, 8 years ago

trunk r31482 "Fix clang -Wshorten-64-to-32 warnings in port/ subdir (#6218)"

comment:2 by Even Rouault, 8 years ago

Global pass on -Wshorten-64-to-32 finished... mostly in r31640

comment:3 by Even Rouault, 8 years ago

trunk r31777, r31778, r31779 "Remove leading underscore or double underscore before our #define identifiers"

comment:4 by Even Rouault, 8 years ago

trunk r31784 "Enable -Wreserved-id-macro when available, and add exceptions for third-party headers (#6218)"

comment:5 by Even Rouault, 8 years ago

trunk r31787 "Revert r31784 'Enable -Wreserved-id-macro when available, and add exceptions for third-party headers'. It breaks GCC that doesn't support '#pragma GCC diagnostic ignored \"-Wreserved-id-macro\" (#6218)"

comment:6 by Even Rouault, 5 years ago

Milestone: closed_because_of_github_migration
Resolution: wontfix
Status: newclosed

This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub. If you believe this ticket is still valid, you may file it to https://github.com/OSGeo/gdal/issues if it is not already reported there.

Note: See TracTickets for help on using tickets.