dl_malloc warnings from clang 3.9.1

Issue #15 resolved
Dan Bonachea created an issue

Seeing the following warnings from clang 3.9.1 building the dl_malloc objects:

clang -std=c11 -D_GNU_SOURCE=1 -I/cygdrive/e/Dan/UPC/upcxx/.nobs/art/c51aa880b49f4d88ade14ad7a0371a3f3466326d -MM -MT x /cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c

/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:595:5: warning: macro expansion
      producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if USE_LOCKS /* Spin locks for gcc >= 4.1, older gcc on x86, MSC >= 1310 */
    ^
/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:591:22: note: expanded from macro
      'USE_LOCKS'
#define USE_LOCKS  ((defined(USE_SPIN_LOCKS) && USE_SPIN_LOCKS != 0) || \
                     ^
/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:595:5: warning: macro expansion
      producing 'defined' has undefined behavior [-Wexpansion-to-defined]
/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:592:22: note: expanded from macro
      'USE_LOCKS'
                    (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0))
                     ^
/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:1497:5: warning: macro expansion
      producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if USE_LOCKS
    ^
/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:591:22: note: expanded from macro
      'USE_LOCKS'
#define USE_LOCKS  ((defined(USE_SPIN_LOCKS) && USE_SPIN_LOCKS != 0) || \
                     ^
/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:1497:5: warning: macro expansion
      producing 'defined' has undefined behavior [-Wexpansion-to-defined]
/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:592:22: note: expanded from macro
      'USE_LOCKS'
                    (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0))
                     ^
/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:1807:6: warning: macro expansion
      producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if !USE_LOCKS
     ^
/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:591:22: note: expanded from macro
      'USE_LOCKS'
#define USE_LOCKS  ((defined(USE_SPIN_LOCKS) && USE_SPIN_LOCKS != 0) || \
                     ^
/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:1807:6: warning: macro expansion
      producing 'defined' has undefined behavior [-Wexpansion-to-defined]
/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:592:22: note: expanded from macro
      'USE_LOCKS'
                    (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0))
                     ^
/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:2599:5: warning: macro expansion
      producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if USE_LOCKS
    ^
/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:591:22: note: expanded from macro
      'USE_LOCKS'
#define USE_LOCKS  ((defined(USE_SPIN_LOCKS) && USE_SPIN_LOCKS != 0) || \
                     ^
/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:2599:5: warning: macro expansion
      producing 'defined' has undefined behavior [-Wexpansion-to-defined]
/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:592:22: note: expanded from macro
      'USE_LOCKS'
                    (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0))
                     ^
/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:2649:5: warning: macro expansion
      producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if USE_LOCKS
    ^
/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:591:22: note: expanded from macro
      'USE_LOCKS'
#define USE_LOCKS  ((defined(USE_SPIN_LOCKS) && USE_SPIN_LOCKS != 0) || \
                     ^
/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:2649:5: warning: macro expansion
      producing 'defined' has undefined behavior [-Wexpansion-to-defined]
/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:592:22: note: expanded from macro
      'USE_LOCKS'
                    (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0))
                     ^
/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:2747:5: warning: macro expansion
      producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if USE_LOCKS
    ^
/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:591:22: note: expanded from macro
      'USE_LOCKS'
#define USE_LOCKS  ((defined(USE_SPIN_LOCKS) && USE_SPIN_LOCKS != 0) || \
                     ^
/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:2747:5: warning: macro expansion
      producing 'defined' has undefined behavior [-Wexpansion-to-defined]
/cygdrive/e/Dan/UPC/upcxx/src/dl_malloc.c:592:22: note: expanded from macro
      'USE_LOCKS'
                    (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0))
                     ^
12 warnings generated.

Dan@turtle ~/UPC/upcxx
$ git describe
fatal: No tags can describe '6c3a3cbcaddc4c107ce69bf26d1f235c05ef3e83'.
Try --always, or create some tags.

Dan@turtle ~/UPC/upcxx
$ clang --version
clang version 3.9.1 (tags/RELEASE_391/final)
Target: x86_64-unknown-windows-cygnus
Thread model: posix
InstalledDir: /usr/bin

Dan@turtle ~/UPC/upcxx
$ uname -a
CYGWIN_NT-6.1 turtle 2.8.0(0.309/5/3) 2017-04-01 20:47 x86_64 Cygwin

Comments (2)

  1. Dan Bonachea reporter

    fix issue #15: dl_malloc warnings

    This fixes a naive definition of a preprocessor conditional expression that led to undefined bahvior and warnings from clang.

    My replacement is semantically identical to what the code was attempting to accomplish, without relying on undefined behavior.

    → <<cset d4e7e3c30315>>

  2. Log in to comment