octave-maintainers
[Top][All Lists]
Advanced

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

rc/ov.h:166: warning: 'octave_value::rep' should be initialized in the m


From: CdeMills
Subject: rc/ov.h:166: warning: 'octave_value::rep' should be initialized in the member initialization list
Date: Fri, 14 Jan 2011 10:25:59 -0800 (PST)

Could someone please enlighten my weak comprehension of C++ with regard to
ov.h ?

Line 166:
octave_value (void)
    {
      static octave_base_value nil_rep;
      rep = &nil_rep;
      rep->count++;
    }

Line 1174:
protected:

  // The real representation.
  octave_base_value *rep;

It looks like an implementation of reference counting and smart pointer:

 ~octave_value (void)
  {
    if (--rep->count == 0)
      delete rep;
  }

But why this static declaration of some object inside the ctor ? Unique for
all objects of this class ? Equivalent to a closure ?

Moreover, as count is an octave_idx_type, which is an int, shouldn't case
where count < 0 be detected and flagged  ? They should not occur, but 
better sure than sorry.

Regards

Pascal
-- 
View this message in context: 
http://octave.1599824.n4.nabble.com/rc-ov-h-166-warning-octave-value-rep-should-be-initialized-in-the-member-initialization-list-tp3218135p3218135.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]