compile or not compile

Karol Szkudlarek karol@mikronika.com.pl
Fri Jul 2 08:09:00 GMT 2004


llewelly@xmission.com wrote:
> Karol Szkudlarek <karol@mikronika.com.pl> writes:
> 
> 
>>Eljay Love-Jensen wrote:
>>
>>
>>>Hi Karo,
>>>
>>>Add this to your class A:
>>>
>>>int foo(Items const&)
>>>{
>>>  std::cerr << "A::Items\n";
>>>  return 0;
>>>}
>>>
>>>HTH,
>>>--Eljay
>>>
>>
>>Hi!
>>
>>I can't use you solution in my code because in real example I have
>>little different sitiuation.
>>In my second test case I try to explain more precisely my real
>>case. Look at the following code:
>>
>>// SECOND_CASE
>>typedef int my_int;
>>
>>class ALibraryClass
>>{
>>
>>public:
>>    int foo(const my_int&)
>>        {
>>            return 0;
>>        }
>>    int foo(const bool&)
>>        {
>>            return 0;
>>        }
>>};
>>
>>class BClientClass
>>{
>>    public:
>>    enum Items
>>    {
>>        item1=1000,
>>        item2=2000
>>    };
>>    void test()
>>    {
>>        ALibraryClass a;
>>        a.foo(BClientClass::item1);
> 
> 
> This should select A::foo(const my_int&) unambigously; enum to int is
>     a promotion (see 4.5) while enum to bool is a conversion (4.12)
>     and a promotion is a better match than conversion, (13.3.3.2/4).

Those above explain me everything. Thanks. I wrote and tested on my 
"broken" suse the following program:
typedef int my_int;
void foo(const my_int& a)
{
}
void foo(const bool& b)
{
}
enum Items
{
    item1,item2
};
int main()
{
    foo(item1);
}
and something must be wrong when arguments are references because when
I remove references program compiles fine.

> 
> 
>>    }
>>};
>>
>>int main()
>>{
>>    BClientClass b;
>>    b.test();
>>    return 0;
>>}
>>
>>In class ALibraryClass I can't define int foo(Items const&)
>>because I know nothing about enum Items from client class BClientClass.
>>
>>
>>Generally I would like to know why this program compiles fine (gcc 3.3.3)
>>under Debian but does not compile under Suse (gcc 3.3.3).  Is it possible
>>such a difference in compiling results with the same versions of
>>compiler?
> 
> 
> You aren't really using the same compiler versions. For reasons known
>     only to those who build distros, nearly every linux distro (and
>     each BSD too!) maintains its own set of patches for gcc; what
>     SUSE calls GCC 3.3.3 is actually a SUSE-special derivative of FSF
>     GCC 3.3.3, what debian calls GCC 3.3.3 is a debian-special
>     derivative of FSF GCC 3.3.3, and they are not really the same -
>     only mostly the same. Most of the time, you won't run into the
>     differences, but sometimes ...
> 
> FWIW, FSF GCC 3.3.3 and 3.4 like it, FBSD GCC 2.95.3 and 3.3.3 like
>     it, and slackware-9.0 GCC 3.2.2 like it. I think you should report
>     a bug to SUSE.
> 


Once again thank you very much for help. I try once again report a bug 
to suse because when I sent bug report couple days ago I got interesting 
answer:

"Unfortunately, we cannot provide any support to fix this problem. 
Please, understand that we dont have any control on the developemnt of 
this package. But, if we made any error packaging the compiler, we need 
to know it at the form I already sent to you.

So far, we are not aware about any problem in this package."

says about gcc.

Greets, Karol



More information about the Gcc-help mailing list