[[email protected]: sid doesn't build with gcc 4.0.x]

"Frank Ch. Eigler" <[email protected]>
Newsgroups gmane.comp.emulators.sid.devel
Message-ID <[email protected]>
From: Aldy Hernandez <[email protected]>
To: [email protected] [...]
Subject: sid doesn't build with gcc 4.0.x

Hi folks.

Sid is not building with GCC 4.0 or above.  The problem is in
component/cgen-cpu/cgen-cpu.h's use of reinterpret_cast.  The
reinterpret_cast construct is not allowed amongst integers.

Section 5.2.10 of the C++ specs list the specific set of conversions
allowed by the construct.  Converting from an integer to itself is
not among them.

Jason mentioned that y'all probably want to use static_cast.

I also ran into a template problem which I tried fixing.  The patch
below showed no regressions when testing with GCC 3.4, but still has
more regressions than 3.4 when building sid with 4.0.

I'm not very C++ savvy (at all).  I was hoping one of you cgen fancy
folks could please take a look at this.

The patch below is what you need to at least build with 4.0.

Cheers.
Aldy

	* component/interrupt/components.h (bus_size): Fix constructor to
	be legitimate C++.

	* component/cgen-cpu/cgen-cpu.h (GETMEMSF): Change
	reinterpret_cast to static_cast.
	(SETMEMSF): Same.
	(GETMEMDF): Same.
	(SETMEMDF): Same.

Index: component/interrupt/components.h
===================================================================
RCS file: /cvs/src/src/sid/component/interrupt/components.h,v
retrieving revision 1.6
diff -c -p -r1.6 components.h
*** component/interrupt/components.h	6 Feb 2003 20:40:26 -0000	1.6
--- component/interrupt/components.h	30 Jun 2005 15:12:20 -0000
*************** private:
*** 223,229 ****
  // functions in template class
  
  template<class bus_size>
! IntController<bus_size>::IntController<bus_size>
    (host_int_4 num_irq,
     host_int_4 num_fiq,
     host_int_4 ctrlr_features):
--- 223,229 ----
  // functions in template class
  
  template<class bus_size>
! IntController<bus_size>::IntController
    (host_int_4 num_irq,
     host_int_4 num_fiq,
     host_int_4 ctrlr_features):
Index: component/cgen-cpu/cgen-cpu.h
===================================================================
RCS file: /cvs/src/src/sid/component/cgen-cpu/cgen-cpu.h,v
retrieving revision 1.13
diff -c -p -r1.13 cgen-cpu.h
*** component/cgen-cpu/cgen-cpu.h	3 Jun 2005 20:25:39 -0000	1.13
--- component/cgen-cpu/cgen-cpu.h	30 Jun 2005 15:12:20 -0000
*************** public:
*** 172,194 ****
    inline SF
    GETMEMSF(PCADDR pc, IADDR addr)
      {
!       return reinterpret_cast<SF>(this->read_insn_memory_4 (pc, addr));
      }
    inline void
    SETMEMSF(PCADDR pc, ADDR addr, SF value)
      {
!       return this->write_insn_memory_4 (pc, addr, reinterpret_cast<USI>(value));
      }
  
    inline DF
    GETMEMDF(PCADDR pc, IADDR addr)
      {
!       return reinterpret_cast<DF>(this->read_insn_memory_8 (pc, addr));
      }
    inline void
    SETMEMDF(PCADDR pc, ADDR addr, DF value)
      {
!       return this->write_insn_memory_8 (pc, addr, reinterpret_cast<UDI>(value));
      }
  
    // IMEM: instruction memory calls
--- 172,194 ----
    inline SF
    GETMEMSF(PCADDR pc, IADDR addr)
      {
!       return static_cast<SF>(this->read_insn_memory_4 (pc, addr));
      }
    inline void
    SETMEMSF(PCADDR pc, ADDR addr, SF value)
      {
!       return this->write_insn_memory_4 (pc, addr, static_cast<USI>(value));
      }
  
    inline DF
    GETMEMDF(PCADDR pc, IADDR addr)
      {
!       return static_cast<DF>(this->read_insn_memory_8 (pc, addr));
      }
    inline void
    SETMEMDF(PCADDR pc, ADDR addr, DF value)
      {
!       return this->write_insn_memory_8 (pc, addr, static_cast<UDI>(value));
      }
  
    // IMEM: instruction memory calls
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.