From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11753 invoked by alias); 20 Nov 2013 14:53:30 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 11743 invoked by uid 89); 20 Nov 2013 14:53:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RDNS_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mail-ee0-f41.google.com Received: from Unknown (HELO mail-ee0-f41.google.com) (74.125.83.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 20 Nov 2013 14:53:28 +0000 Received: by mail-ee0-f41.google.com with SMTP id t10so2816157eei.14 for ; Wed, 20 Nov 2013 06:53:19 -0800 (PST) X-Received: by 10.14.177.199 with SMTP id d47mr1510589eem.14.1384959199305; Wed, 20 Nov 2013 06:53:19 -0800 (PST) Received: from [192.168.1.5] (host120-227-static.228-95-b.business.telecomitalia.it. [95.228.227.120]) by mx.google.com with ESMTPSA id z1sm60873518eeo.14.2013.11.20.06.53.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 20 Nov 2013 06:53:18 -0800 (PST) Message-ID: <528CCCCD.3030601@gmail.com> Date: Wed, 20 Nov 2013 16:30:00 -0000 From: Riccardo Manfrin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: gcc-help Subject: virtual table Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2013-11/txt/msg00146.txt.bz2 Hi, suppose I have three classes Foo, Bar, Zoo. Foo inherits from Bar, Bar inherits from Zoo. Bar and Zoo are abstract classes (as defined here : http://en.wikibooks.org/wiki/C%2B%2B_Programming/Classes/Abstract_Classes) The size of Foo shall account for the two pointers to Bar an Zoo vtables. I was wondering if there is a way to have the Zoo vtable reference pointer embedded in the Bar vtable, so that Foo only has to store one pointer, while the second vtable reference is resolved when accessing the first. I'm aware that there are motivations like casting or multiple inheritance behind having all vtables pointers attached to the object instance in "ram" memory, rather then within the vtable "in rom", but I was wondering if there was a more "ram-efficient" way to handle this (as the vtables and the way the work is not dictated by the standard), which gcc could support. R