summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.robertl/eb112.C
blob: 69ee83c7df5bd6f6077b461d1a7f4aea562d1e0f (plain)
1
2
3
4
5
6
7
8
9
10
11
// { dg-do assemble  }
template <class STRUCT, class MEMBER> inline STRUCT *
setback(MEMBER *bp, MEMBER STRUCT::*offset)
{
        // The implementation of this function may be platform dependend
        if(!bp) return 0; // NULL pointers remain NULL
        union { int i; MEMBER STRUCT::*of; } u; // Switch types. Casting won't work.
        u.of = offset;
        return (STRUCT *) ((int) bp - u.i);
}