public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Problem default type converting
@ 2002-10-08  1:39 Henrik Nilsson (Developer)
  2002-10-08  2:01 ` Sebastian Huber
  2002-10-08  2:06 ` Rupert Wood
  0 siblings, 2 replies; 3+ messages in thread
From: Henrik Nilsson (Developer) @ 2002-10-08  1:39 UTC (permalink / raw)
  To: gcc-help


I'm using GCC 2.96 on Linux
My code

class CString{
	CString()
	CString(const char *)
}

class MyClass{
	f(const CString  &s){}
}

MyClass my;
my.f("")

Then I get compiler error.
Due to the C++ standard my.f("") should create a temp object like this
my.f(CString("")) but instead
I get compiler error

This is not a big problem I'm just surprised that it seems like GCC is not
following the standard.

Any one who know more abot this?
Henrik






^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Problem default type converting
  2002-10-08  1:39 Problem default type converting Henrik Nilsson (Developer)
@ 2002-10-08  2:01 ` Sebastian Huber
  2002-10-08  2:06 ` Rupert Wood
  1 sibling, 0 replies; 3+ messages in thread
From: Sebastian Huber @ 2002-10-08  2:01 UTC (permalink / raw)
  To: gcc-help

Hello Henrik,
your C++ is correct and compiles at least with 2.95.3. I guess that you have 
discoverd another shortcomming of gcc 2.96.

Ciao
 
On Tuesday 08 October 2002 01:36, Henrik Nilsson \(Developer\) wrote:
> I'm using GCC 2.96 on Linux
> My code
>
> class CString{
> 	CString()
> 	CString(const char *)
> }
>
> class MyClass{
> 	f(const CString  &s){}
> }
>
> MyClass my;
> my.f("")
>
> Then I get compiler error.
> Due to the C++ standard my.f("") should create a temp object like this
> my.f(CString("")) but instead
> I get compiler error
>
> This is not a big problem I'm just surprised that it seems like GCC is not
> following the standard.
>
> Any one who know more abot this?
> Henrik

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Problem default type converting
  2002-10-08  1:39 Problem default type converting Henrik Nilsson (Developer)
  2002-10-08  2:01 ` Sebastian Huber
@ 2002-10-08  2:06 ` Rupert Wood
  1 sibling, 0 replies; 3+ messages in thread
From: Rupert Wood @ 2002-10-08  2:06 UTC (permalink / raw)
  To: Henrik Nilsson (Developer); +Cc: gcc-help

On Tue, 8 Oct 2002, Henrik Nilsson (Developer) wrote:

> I'm using GCC 2.96 on Linux
:
> Then I get compiler error.
> Due to the C++ standard my.f("") should create a temp object like this
> my.f(CString("")) but instead I get compiler error

I only have 2.95 to test here, but this code (derived from yours) compiles
cleanly on full warnings:

    class CString
    {
        public:
            CString();
            CString(const char *);
    };

    class MyClass
    {
        public:
            void f(const CString &s);
    };

    int main(void)
    {
        MyClass my;
        my.f("");

        return 0;
    }

and fails to link citing both MyClass::f and CString::CString(const char*).

Are you sure that you haven't made another mistake? Did you build with
'-Wall'? What's the compiler error? Does my version work?

Alternatively, have you somehow flagged the CString(const char*)
constructor as explicit-only (an __attribute__?) or forbidden implicit
construction via a command line switch? I can't see any that do that from
a quick scan of the manual.

Rup.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-10-08  9:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-08  1:39 Problem default type converting Henrik Nilsson (Developer)
2002-10-08  2:01 ` Sebastian Huber
2002-10-08  2:06 ` Rupert Wood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).