[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: 2.2.11

Richard Henderson wrote:
>   (2) Give -fno-strict-alias to gcc 2.95.  No matter what we do for
>       2.3, we won't be going back to fix what needs fixing in 2.2.

Is this good enough?  Here is a code distilled from a real program
(lyx-1.0.3) which was falling flat on this trouble and, curiously enough,
in the original C++ source things were not really that obvious. :-)

#include <stdio.h>
#include <string.h>

unsigned char buffer[sizeof(char *) + 2];

main ()
    unsigned char *p;
    int i;
    p = (unsigned char *)&p;            /* cheap initialization */
    printf("original = %p\n", p);
#if defined(BUG)
    memcpy (&buffer[1], &p, sizeof(p));
        unsigned char *target, *source;
        target = &buffer[1];
        source = (unsigned char *)&p;
        for (i = 0; i < sizeof(char *) ; i++) {
            *target++ = *source++;
    for (i = sizeof(char *) + 2; i > 0 ; ) {
        printf("%02x ", buffer[--i]);

This program compiled on Alpha with egcs egcs-1.1.2 release
(egcs-2.91.66 19990314) when BUG constant is not defined **or** when
no optimizations are used prints someting like that:

original = 0x11ffffb60
00 00 00 00 01 1f ff fb 60 00

If you add -DBUG to compilation flags and use **any** level of
optimization above -O0 then this printout will be

original = 0x11ffffb60
00 00 00 00 00 00 00 00 60 00

Adding compilation flags like -fno-strict-aliasing or other aliasing
related flags does not change anything at all.  Looking at an assembler
output it appears that this is the case of an overenthusiastic expansion
of an inline function - but I am not sure.

I think that I will file a formal bug report - unless I will be told
that this bug variant is well known, and taken care of, and I simply
live under a rock.

Oh, and after a small workaround in one place in a source file
math_iter.C, LyX-1.0.3 compiled on Alpha with all optimizations seems
to be doing just fine.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []