Re: A basic (?) problem with addresses (gcc)





"Seebs" <usenet-nospam@xxxxxxxxx> wrote in message
news:slrnigkle6.26q4.usenet-nospam@xxxxxxxxxxxxxxxxxx
On 2010-12-16, BartC <bc@xxxxxxxxxx> wrote:
OK. But apart from the inconvenience of wrapping these things in unions
then
having to use field selection to access the data, how do you do something
like this:

integer*4 i(20)
real*8 a
equivalance (a,i(7))

(So the 8 bytes at i(7..8) are shared with the floating point number.)

You don't. C doesn't support or allow for overlap like this, so far as I
know.

The Fortran example was to demonstrate what I meant. But in fact I use that
construction in another language, and it looks like this:

[20]int i
real a @ &i[7]

(although actual uses are usually more straightforward).

From time to time it might be necessary to rewrite that in C, and I relied
on the OP's trick to do the conversion. Now it seems that that may not work,
not because there's some weird hardware involved, but because some compilers
might exploit a 'loophole' in the standard so that they can get away with a
cheap optimisation, even thought the hardware wouldn't have a problem with
it.

That sounds wrong. It also seems like something that C ought to be capable of: directly specifying an address where you want something stored, even if relative to the address of another object.

--
Bartc

.



Relevant Pages

  • Re: VMS
    ... because it was tailored to the platform rather than the language. ... > best machine architecture (PDP-11, VAX, Alpha) and the best software. ... the hardware really didn't matter. ... applications and in the IT world bus speed is more important than ALU ...
    (comp.object)
  • Re: Cells compared to Flow-Based Programming
    ... Given that it's not even possible to proof hardware, ... a language with imperative features is inherently ... of the acquired company that they don't like. ...
    (comp.lang.lisp)
  • Re: a dozen cpus on a chip
    ... No nontrivial language can ever be proven to be imposible to crash. ... compilers still available which implement ISO M2. ... It is a common misconception that Lisp is always interpretted. ... various X86 machines the hardware does exist that could allow the OS ...
    (sci.electronics.design)
  • Re: How much intelligence?
    ... Curt believes in things that have hardware that enables them to talk. ... have the same language skills we have. ... These representations of reality are represented in long-term memory, ...
    (comp.ai.philosophy)
  • Re: Another transputer-inspired language?
    ... describe permanent ASIC/VLSI hardware devices. ... only support Verilog & VHDL. ... shrinking but the no of FPGA starts is exploding due to lowish NRE ... When I suggest the V++ language be modeled after ...
    (comp.sys.transputer)