[EMAIL PROTECTED]:/tmp% cat test.c
#ifdef __cplusplus
extern "C"
#endif
void abort(void);

__attribute__((noinline))
unsigned long f(const unsigned long x) {
    struct { unsigned long x : 1; } s;
    s.x = x;
    return s.x;
}

int main() {
    if (f(3) != 1)
        abort();
}
[EMAIL PROTECTED]:/tmp% gcc test.c && ./a.out   
[EMAIL PROTECTED]:/tmp% g++ test.c && ./a.out  
[EMAIL PROTECTED]:/tmp% g++ -O test.c && ./a.out 
zsh: abort (core dumped)  ./a.out

not a problem with 4.0 or earlier


-- 
           Summary: [4.1,4.2 regression] bit-field value not narrowed
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: falk at debian dot org
 GCC build triplet: alphaev68-unknown-linux-gnu
  GCC host triplet: alphaev68-unknown-linux-gnu
GCC target triplet: alphaev68-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27083

Reply via email to