https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64703

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #8 from Martin Sebor <msebor at gcc dot gnu.org> ---
The test case is invalid because it accesses the value of the opd object via a
pointer to a function when C allows an object to have its value accessed only
by an lvalue of a compatible type.

A simpler test case that demonstrates a similar issue is below:

#include <assert.h>

struct X { const char *s; };
struct Y { unsigned long n; };

const char* __attribute__ ((weak))
foo (unsigned long value) {
    struct Y y;

    if (value) {
        y.n = ((struct Y*)value)->n;
        value = (unsigned long)&y;
    }

    return ((struct X*)value)->s;
}

int main (void) {
    struct Y y = { 123 }; 

    unsigned long n = (unsigned long)foo ((unsigned long)&y);

    assert (n == y.n);

    return 0;
}

Reply via email to