Coda File System

Re: did I hit that compiler bug?

From: Jan Harkes <>
Date: Tue, 26 Aug 2003 11:29:43 -0400
On Tue, Aug 26, 2003 at 09:54:49AM -0400, Matthias Drochner wrote:
> Now I'm seeing in the 6.0.1 announcement:
>     Fixes a miscompilation of a code fragment with some gcc compilers.
>     This lead to various crashes mostly in and around various list
>     iterators. This affected pretty much anyone who built Coda with
>     an not so bleeding edge version of the gnu C++ compiler (2.95.3,
>     3.0, 3.1, 3.2.1?)
> My compiler is 2.95.3.
> It _might_ be possible that the NetBSD pkgsrc build environment
> thwarts such a fix by passing "-O2" through the environment.
> So before I'm looking into the wrong direction, just a question:
> Is that the bug I hit, and how was it fixed?

It might be that bug. First of all I'm not sure whether I bumped the RVM
version number although the RVM layout has changed significantly which
could also account for fso iterator problems. So after installing 6.0.2
you would have to start venus with -init at least once.

I think I always pass -O2, so that shouldn't cause a problem. On the
other hand I'm not sure whether the configure test is ran with -O2 so
you might have optimized the test away.

The bug is probed by configure (checking if ptr-to-member works...),
and it comments out the CODA_PTR_TO_MEMBER define in config.h if it
fails. I just built the following test program and -O2 doesn't affect
the result of the test for me.

    /* c++ -o ptrtomem ; ./ptrtomem ; echo $? */
    /* if the return code is 1, &A::B does not return the
     * correct offset of the B member within class A */
    #include <sys/types.h>
    struct b { struct b *C; };
    class A { public: struct b B; };
    main() {
	A *a;
	if (((char *)&a->B - (size_t)(&A::B)) != (char *)a)
	    return 1;

The workaround is to use offsetof(A, B), which is defined in stddef.h.
But that generates warnings with gcc-3.0 compilers.

These compilers do not work correctly,
    gcc version egcs-2.90.27 980315 (egcs-1.0.2 release)
    gcc version 2.95.4 20011002 (Debian prerelease)

But it works fine with,
    gcc version 3.2.2
    gcc version 3.3.2 20030812 (Debian prerelease)

Received on 2003-08-26 11:32:14