From 76b75624bc300eba2d20a5926526acfa5f1b8368 Mon Sep 17 00:00:00 2001 From: Mike Hamburg Date: Sat, 9 Aug 2014 14:34:50 -0700 Subject: [PATCH] Thanks again Samuel Neves: the "gcc bug" is actually undefined behavior caused by strict aliasing. For now just passing -fno-strict-aliasing, maybe unions to fix it later --- Makefile | 2 +- src/arch_x86_64/p448.h | 14 ++------------ src/scalarmul.c | 4 ---- 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index aac33e4..28d3603 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ WARNFLAGS = -pedantic -Wall -Wextra -Werror -Wunreachable-code \ INCFLAGS = -Isrc/include -Iinclude -Isrc/$(ARCH) -LANGFLAGS = -std=c99 +LANGFLAGS = -std=c99 -fno-strict-aliasing GENFLAGS = -ffunction-sections -fdata-sections -fvisibility=hidden -fomit-frame-pointer -fPIC OFLAGS = -O3 diff --git a/src/arch_x86_64/p448.h b/src/arch_x86_64/p448.h index 56c62a9..59de4ff 100644 --- a/src/arch_x86_64/p448.h +++ b/src/arch_x86_64/p448.h @@ -89,21 +89,11 @@ p448_is_zero ( const p448_t *in ); -static -#ifndef GCC_HAS_A_BUG_SO_DONT_INLINE_FIELD_BIAS - __inline__ -#endif -void +static __inline__ void p448_bias ( p448_t *inout, int amount -) -#ifdef GCC_HAS_A_BUG_SO_DONT_INLINE_FIELD_BIAS - __attribute__((unused,noinline,optimize("O1"))) -#else - __attribute__((unused,always_inline)) -#endif -; +) __attribute__((unused,always_inline)); void p448_mul ( diff --git a/src/scalarmul.c b/src/scalarmul.c index e5e3237..49bd242 100644 --- a/src/scalarmul.c +++ b/src/scalarmul.c @@ -1,10 +1,6 @@ /* Copyright (c) 2014 Cryptography Research, Inc. * Released under the MIT License. See LICENSE.txt for license information. */ -#if (defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__)) - /* This works around an apparent compiler bug in GCC, thanks Samuel Neves */ - #define GCC_HAS_A_BUG_SO_DONT_INLINE_FIELD_BIAS -#endif #include "word.h"