Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid the direct use of 'defined' in macro expansion #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

juergenhoetzel
Copy link

If a defined operator appears as the result of a macro expansion, the
C standard specifies the behavior as undefined.

Fixes "-Wexpansion-to-defined" warnings produced by clang >=3.9:

poly1305-donna.c:18:6: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if (HAS_SIZEOF_INT128_64BIT || HAS_MSVC_64BIT || HAS_GCC_4_4_64BIT)
     ^
poly1305-donna.c:14:34: note: expanded from macro 'HAS_SIZEOF_INT128_64BIT'
#define HAS_SIZEOF_INT128_64BIT (defined(__SIZEOF_INT128__) && defined(__LP64__))
                                 ^
poly1305-donna.c:18:6: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
poly1305-donna.c:14:64: note: expanded from macro 'HAS_SIZEOF_INT128_64BIT'
#define HAS_SIZEOF_INT128_64BIT (defined(__SIZEOF_INT128__) && defined(__LP64__))
                                                               ^
poly1305-donna.c:18:33: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if (HAS_SIZEOF_INT128_64BIT || HAS_MSVC_64BIT || HAS_GCC_4_4_64BIT)
                                ^
poly1305-donna.c:15:25: note: expanded from macro 'HAS_MSVC_64BIT'
#define HAS_MSVC_64BIT (defined(_MSC_VER) && defined(_M_X64))
                        ^
poly1305-donna.c:18:33: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
poly1305-donna.c:15:46: note: expanded from macro 'HAS_MSVC_64BIT'
#define HAS_MSVC_64BIT (defined(_MSC_VER) && defined(_M_X64))
                                             ^
poly1305-donna.c:18:51: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if (HAS_SIZEOF_INT128_64BIT || HAS_MSVC_64BIT || HAS_GCC_4_4_64BIT)
                                                  ^
poly1305-donna.c:16:28: note: expanded from macro 'HAS_GCC_4_4_64BIT'
#define HAS_GCC_4_4_64BIT (defined(__GNUC__) && defined(__LP64__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4))))
                           ^
poly1305-donna.c:18:51: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
poly1305-donna.c:16:49: note: expanded from macro 'HAS_GCC_4_4_64BIT'
#define HAS_GCC_4_4_64BIT (defined(__GNUC__) && defined(__LP64__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4))))

Issue appeared in john the ripper:

If a defined operator appears as the result of a macro expansion, the
C standard specifies the behavior as undefined.

Fixes "-Wexpansion-to-defined" warnings produced by clang >=3.9.
@solardiz
Copy link

Looks like #5 is a different attempt at fixing the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants