Re: (undocumented?) difference between gcc 4.6 and 4.7 (C++ implicit template instantiation)

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

 



Thank you, Jonathan, for your quick reply.

Jonathan Wakely <jwakely.gcc@xxxxxxxxx> writes:

> On 28 August 2012 16:32, Christoph Groth wrote:
>> I've been unable to find a description of this issue in any changelog.
>> Actually, I wonder whether the behavior of 4.6 or that of 4.7 is the
>> correct one with regard to the C++ language standard.
>>
>> Is this a known issue which has been fixed in 4.7, or rather a
>> regression from 4.6?
>
> The change in behaviour might be due to the patch for
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48883
>
> But I think the program has undefined behaviour according to
> [expr.reinterpret.cast]/6, because it calls a function through a
> pointer to a different function type.  Specifically, something<long>
> which has type void*(Class<long>*) is called through a pointer of type
> void*(*)(void*).

Unfortunately, this is the official way of programming Python extensions
in C/C++. [1]  The void* of my example stands for PyObject*.

I'm not sure whether the behavior is indeed undefined when
something<long> will be called through a pointer of type void*(*)(void*)
IF the void* argument always points to a Class<long> object.

So, I guess, I either have to keep all the explicit instantiations in my
program (many) or make all these template functions static methods of a
class which can then be instantiated explicitly with a single statement.

[1] http://docs.python.org/py3k/extending/newtypes.html


[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