Re: possible bug in g++

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

 



Hmmm, I see the problem. I just find very confusing that the
compilation of wrong code be compiler dependent or version dependent.
Wouldn't it be better to mark it as invalid code and to signal it?
Maybe one could allow the compiler to accept the code with a
-fpermissive flag. Anyway, thanks a lot!

Best,

M


On Thu, Feb 16, 2012 at 1:47 AM, Jonathan Wakely <jwakely.gcc@xxxxxxxxx> wrote:
> On 15 February 2012 22:17, Mattia Jona-Lasinio wrote:
>> Hi Jonathan,
>>
>> I don´t think this link applies. It is clear that linking will fail in
>> the link examples because the static variables are declared but never
>> defined,
>
> Right, just like your code.
>
>> i.e. they are never instantiated.
>
> No, it's not to do with instantiation.
>
> It's the same problem, your program is invalid and can be fixed by
> adding definitions of the variables.
>
>> On the other hand the difference between the non working versions
>>
>> std::cout << (b = aa< X<4> >(3))[1].v << std::endl;
>
> The operator<< overload used here takes its argument by reference.
> Binding a reference to an object requires the object to have an
> address, so you need to provide a definition.
>
> Read the FAQ more carefully.  Your program is invalid. The compiler is
> not required to issue a diagnostic, so it *might* accept it, as in
> your final example, but that doesn't mean the code is correct. The
> code is still wrong.
>
> You can fix it by adding a definition:
>
> template<int T> const int X<T>::v;



[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