This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: virtual inline vs inline
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Norbert Dajka <daatno at gmail dot com>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Mon, 4 Nov 2013 14:50:49 +0000
- Subject: Re: virtual inline vs inline
- Authentication-results: sourceware.org; auth=none
- References: <CABD7AnWSuEAez73wO0u=_Nj=p=K8xcc4SOd1maDfpoJqX4jauA at mail dot gmail dot com>
On 4 November 2013 13:33, Norbert Dajka wrote:
> Hello,
>
> I would like to know, if there is any difference (in allocated memory
> space) between defining a function inline in the class declaration
> (with the inline word), and defining a function inline explicit after
> the class declaration.
There is no difference.
> In addition, does anybody know, why a previously only inline declared
> function takes up more memory space, if it's declared virtual inline
> (even if the classes to which the declaring class of the function is a
> parent class doesn't have their own implementation)?
Because virtual functions need additional metadata in the class,
specifically in the ABI used by G++ the class must have a pointer to
the vtable (if it didn't have one already) and the vtable will have an
additional entry for the virtual function.