C++ code works on gcc 4.4 but doesn't compile on 4.5.1

Hugo Arregui hugo.arregui@gmail.com
Sat Sep 4 02:42:00 GMT 2010


Thanks for your quick and clear answers Sam!

On Fri, Sep 3, 2010 at 11:40 PM, Sam Varshavchik <mrsam@courier-mta.com> wrote:
> Hugo Arregui writes:
>
>> Thanks Sam! That's a pretty good solution.
>> But, just to be curious, do you know why is working in an older
>> version, and not in the new one?
>
> It's been my experience that each successive major gcc release is more
> diligent when it comes to strict compliance with the C++ language.
>
> Previous versions of gcc might've allowed you to get away with using A or B
> interchangably, with each other, after declaring "typedef A B". However,
> there's probably some obscure part of the C++ language standard which,
> basically, specifies that a typedef is, precisely, a "one way street".
>
> Roughly speaking: "typedef A B" means that "B is the same thing as A", but
> it does not mean that "A is the same thing as B". Or, the other way around,
> depending on your point of view.
>
>> On Fri, Sep 3, 2010 at 10:54 PM, Sam Varshavchik <mrsam@courier-mta.com>
>> wrote:
>>>
>>> Hugo Arregui writes:
>>>
>>>> Hi guys,
>>>>
>>>> as the subject says, I'm having a problem trying to compile the
>>>> attached code with gcc 4.5.1.
>>>> The error is:
>>>>
>>>> test.cpp:16:46: error: prototype for 'typename
>>>> std::list<T>::const_iterator Test<T>::begin() const' does not match
>>>> any in class 'Test<T>'
>>>> test.cpp:11:31: error: candidate is: Test<T>::const_iterator
>>>> Test<T>::begin() const
>>>> make: *** [test] Error 1
>>>>
>>>> I don't see any change related to this topic into the change logs.
>>>> Can you give me a point?
>>>
>>> Try changing your definition to:
>>>
>>> template<class T>
>>> inline typename Test<T>::const_iterator Test<T>::begin() const
>>> {
>>>   return list.begin();
>>> };
>
>



More information about the Gcc-help mailing list