texmacs-dev
[Top][All Lists]
Advanced

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

Re: [Texmacs-dev] GCC 3.2 status update


From: David Allouche
Subject: Re: [Texmacs-dev] GCC 3.2 status update
Date: Wed, 27 Nov 2002 16:31:48 +0100
User-agent: Mutt/1.4i

On Wed, Nov 27, 2002 at 12:08:49AM +0300, Igor V. Kovalenko wrote:
> David Allouche wrote:
> >
> >For memory, here is the relevant code:
> >
> >    inline tree::~tree () {
> >      if ((--rep->ref_count)==0) {
> >        destroy_tree_rep (rep); rep= NULL; } }
> >
> >    void
> >    destroy_tree_rep (tree_rep* rep) {
> >      if (rep->op == STRING)
> >        delete ((atomic_rep*) ((void*) rep));
> >      else
> >        delete ((compound_rep*) ((void*) rep));
> >    }
> >
> >Here are the relevant standard excerpts:
> >
> >  4.1  lvalue to rvalue conversion
> >
> >15
> >   If a programm attempts to access the stored value of an object
> >   through an lvalue of other than one of the following types the
> >   behavior is undefined [The intent of this list is to specify those
> >   circumstances in which an object may or may not be aliased]:
> >
> >   -- the dynamic type of the object,
> >
> >   -- a cv-qualified version of the dynamic type of the object,
> >
> >   -- a type that is the signed or unsigned type corresponding to the
> >      dynamic type of the object,
> >
> >   -- a type that is the signed or unsigned type corresponding to a
> >      cv-qualified version of the dynamic type of the object,
> >   
> >   -- an aggregate or union type that includes one of the
> >      aformentioned types among its members (including, recursively, a
> >      member of a subaggregate or contained union),
> >
> >   -- a type that is a (possibly cv-qualified) base class type of the
> >      dynamic type of the object.
> >
> >   -- a char or unsigned char type.
> 
> If my english is still not that bad :) I can't find the cast to subclass
> type among the listed items... Please correct me.

    1.3.3  dynamic type

    the type of the most derived object (1.8) to which the lvalue
    denoted by a lvalue expression refers. [Example: if a pointer
    (8.3.1) p whose static type is "pointer to class B" is pointing to
    an object of class D, derived from B (clause 10). the dynamic type
    of the expression *p is "D". References (8.3.2) are treated
    similarly. ] The dynamic type of a rvalue expression is its static
    type.

So, destroy_tree_rep never performs a cast to a derived type of the
dynamic type of an object, but only cast *to* the dynamic type.

However, I am unsure that the allocator code strictly respects those
conversion rules. But disabling the allocator does not seem to fix our
problems... However, I would be a good thing to fix that.

The code might violate the conversion rules at some other places. In
the pre-nogencc implementation of the event classes, there was such an
illegal cast (which I removed because nogencc caused it to break). A
good way to look for those problems would be to look for C-style casts
(and replace them by modern casting techniques). I had a quick look at
the code using a regex like ') *[(a-z_A-Z]' (not sure) but I found
nothing incriminating. Maybe someone else should review that too.

-- 
David Allouche         | GNU TeXmacs -- Writing is a pleasure
Free software engineer |    http://www.texmacs.org
   http://ddaa.net     |    http://alqua.com/tmresources
   address@hidden  |    address@hidden
TeXmacs is NOT a LaTeX front-end and is unrelated to emacs.





reply via email to

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