This is the mail archive of the crossgcc@cygnus.com mailing list for the crossgcc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: GCC local variable allocation (M68K)


I have just been working with the Gnu C++ compiler, and using inline
member functions to return a reference to a local object is a slick
way to implement subscripting of bitfields in memory mapped I/O device
registers.  This technique would not work if stack space for block
local objects were recycled the way you want.  It is necessary for the
compiler to generate a stack that expands for the duration of the file
scoped function for the reference to be valid outside the scope of of
the inline member function.  The locals are only reclaimed at the end
of the outermost block that has file scope.

I do think that there is a compiler option to make it behave the way
you want, however.

-- 
--------  "And there came a writing to him from Elijah"  [2Ch 21:12]  --------
Robert Jay Brown III  rj@eli.wariat.org  http://eli.wariat.org  1 847 705-0424
Elijah Laboratories Inc.;  37 South Greenwood Avenue;  Palatine, IL 60067-6328
-----  M o d e l i n g   t h e   M e t h o d s   o f   t h e   M i n d  ------