Browse Source

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

master
Mike Hamburg 10 years ago
parent
commit
76b75624bc
3 changed files with 3 additions and 17 deletions
  1. +1
    -1
      Makefile
  2. +2
    -12
      src/arch_x86_64/p448.h
  3. +0
    -4
      src/scalarmul.c

+ 1
- 1
Makefile View File

@@ -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



+ 2
- 12
src/arch_x86_64/p448.h View File

@@ -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 (


+ 0
- 4
src/scalarmul.c View File

@@ -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"



Loading…
Cancel
Save