Re: Question on overriding operator=

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sep 17, 2012 6:10 PM, "Arthur Schwarz" <aschwarz1309@xxxxxxx> wrote:
>
> gcc 4.5.3
> gdb 4.5.3
> IDE Netbeans 7.2
>
> I've got a little problem with my override of operator=, to wit;
>
> A little code snippet:
>
> [code]
> SlipHeader*  header = new (construct a list);
> SlipHeader& splitHeader = header->splitLeft(*cellPtr[DATASIZE/2]);
> splitHeader = &(header->splitLeft(*cellPtr[DATASIZE/2 + 1]));
> [/code]
>
> class architecture:
> class SlipCellBase
>    class SlipCell : public SlipCellBase
>       class SlipHeader: public SlipCell
>
> The initial allocation and assignment works correctly. The rhs of the second use
> of splitHeader works fine. Problems develop when the equal sign is evaluated.
> What happens is:
>
> 1: Space is allocated on the stack (OK).
> 2: The SlipCellBase constructor is called "SlipCellBase() { }". (OK)
> 3: The SlipCell constructor is called "SlipCell() { }".. (OK)
> 4: The SlipHeader constructor is called "SlipHeader(SlipHeader* header) {
> constructHeader(0); }". (OK)
> 5: On exit from the SlipHeader constructor an unrelated call is made to an
> overridden logical not (operator!=) for a double. Now this I don't understand
> and the overridden code has a 'throw' in it.
>
>
> Each cell is configured as:
> struct {
>    void* operator;
>    SlipCellBase* leftLink;
>    SlipCellBase* rightLink;
> }

 The code is ill-formed because "operator" is a reserved keyword.

>
> Where 'operator' points to an object in global scope containing valid
> (overridden) operators for the type of Slip Cell being created (there are 4
> different types of cells plus a separate class for each of the data types
> supported - 7 additional classes).
>
> And the operator pointer is to a (static) class containing legal operators for
> an object of type SlipHeader, not a class with an object of type double. It
> seems wrong and it's creating havoc. I would like to create an example but I
> have no idea what the root cause is, and munging around with the code will take
> several days. So, is there a call to a logical (or bitwise) not in the normal
> code that gcc generates? Does the flow of control seem ok? Or do you have any
> suggestions as to what I can do to narrow down the problem so that (at least) I
> understand what's wrong?
>
>
> If you can handle the whole nine yards I can send you all my code. The error
> occurs in my main, which consists of a series of tests of my software. All the
> tests, prior to this one, succeed.This test fails at the indicated statement
> above. Compilation of the code takes about 10s and execution to failure takes
> <1s.
>
> thanks
> art
>



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux