Re: CVS build failure with gcc 3.4

Maxwell Krohn <[email protected]> Wed, 15 Dec 2004 08:11:03 -0500
Newsgroups gmane.comp.file-systems.sfs.general
Message-ID <20041215131103.GA2151@debian>
I had the same problem; I believe gcc's implementation of "offsetof"
changed in 3.4.  the workaround i implemented was to make a
"my_offsetof" function in dnsparse.C, defined as the SFS-provided 
offsetof in internal.h, and then to call "my_offsetof" instead of
"offsetof" in dnsparse.C.  I've included a patch.  Obviously, this is
just a temporary solution.  After the offsetof hiccup, though, everything 
seemed to compile fine for me.




Chris Webb ([email protected]) wrote:
> Hi. Just a quick report on building a cvs checkout from today (20041215) on
> gcc 3.4. It fails in async/ as follows:-
> 
> dnsparse.C: In member function `ptr<mxlist> dnsparse::tomxlist()':
> dnsparse.C:528: error: `mxes' cannot appear in a constant-expression
> dnsparse.C:528: error: a function call cannot appear in a constant-expression
> dnsparse.C: In member function `ptr<srvlist> dnsparse::tosrvlist()':
> dnsparse.C:665: error: `recs' cannot appear in a constant-expression
> dnsparse.C:665: error: a function call cannot appear in a constant-expression
> dnsparse.C: In member function `ptr<txtlist> dnsparse::totxtlist()':
> dnsparse.C:717: error: `txtv' cannot appear in a constant-expression
> dnsparse.C:717: error: a function call cannot appear in a constant-expression
> 
> Looks like gcc has become more strict and is breaking on things it
> never broke on before. :-(
> 
> Cheers,
> 
> Chris.
p (text/x-pascal, 2.2 KB)
*** dnsparse.C	Wed Dec 15 08:08:33 2004
--- dnsparse.orig.C	Wed Dec 15 08:08:46 2004
***************
*** 1,4 ****
! /* $Id: dnsparse.C,v 1.8 2004/11/12 15:37:35 max Exp $ */
  
  /*
   *
--- 1,4 ----
! /* $Id: dnsparse.C,v 1.21 2004/07/13 14:24:36 dm Exp $ */
  
  /*
   *
***************
*** 39,47 ****
  #endif /* NEED_DN_EXPAND_DECL */
  }
  
- #define my_offsetof(p_type,field) ((size_t)&(((p_type *)0)->field))
- 
- 
  #if 0
  int
  dn_skipname (const u_char *icp, const u_char *eom)
--- 39,44 ----
***************
*** 527,533 ****
      return NULL;
  
    ref <mxlist> mxl = refcounted<mxlist, vsize>::alloc
!     (my_offsetof (mxlist, m_mxes[mxes.size ()])
       + hintsize (hints.size ()) + nset.size ());
    char *hintp = reinterpret_cast<char *> (&mxl->m_mxes[mxes.size ()]);
    char *namebase = hintp + hintsize (hints.size ());
--- 524,530 ----
      return NULL;
  
    ref <mxlist> mxl = refcounted<mxlist, vsize>::alloc
!     (offsetof (mxlist, m_mxes[mxes.size ()])
       + hintsize (hints.size ()) + nset.size ());
    char *hintp = reinterpret_cast<char *> (&mxl->m_mxes[mxes.size ()]);
    char *namebase = hintp + hintsize (hints.size ());
***************
*** 664,670 ****
    srvrec_randomize (recs.base (), recs.lim ());
  
    ref<srvlist> s = refcounted<srvlist, vsize>::alloc
!     (my_offsetof (srvlist, s_srvs[recs.size ()])
       + hintsize (hints.size ()) + nset.size ());
  
    char *hintp = reinterpret_cast<char *> (&s->s_srvs[recs.size ()]);
--- 661,667 ----
    srvrec_randomize (recs.base (), recs.lim ());
  
    ref<srvlist> s = refcounted<srvlist, vsize>::alloc
!     (offsetof (srvlist, s_srvs[recs.size ()])
       + hintsize (hints.size ()) + nset.size ());
  
    char *hintp = reinterpret_cast<char *> (&s->s_srvs[recs.size ()]);
***************
*** 716,722 ****
    }
  
    ref<txtlist> t = refcounted<txtlist, vsize>::alloc
!     (my_offsetof (txtlist, t_txts[txtv.size ()]) + nchars);
  
    char *dp = (char *) &t->t_txts[txtv.size ()];
    t->t_name = dp;
--- 713,719 ----
    }
  
    ref<txtlist> t = refcounted<txtlist, vsize>::alloc
!     (offsetof (txtlist, t_txts[txtv.size ()]) + nchars);
  
    char *dp = (char *) &t->t_txts[txtv.size ()];
    t->t_name = dp;