public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Missing constructor call...
@ 2002-07-15 17:27 Mike Harrold
  2002-07-15 17:55 ` Gokhan Kisacikoglu
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Harrold @ 2002-07-15 17:27 UTC (permalink / raw)
  To: gcc-help

Hi,

I'm wondering if anyone knows of an existing bug report
for something I have run into.

If I have a class representing iterators, then under
certain circumstances:

  const C::const_iterator start = my_list.begin();
  C::const_iterator iter = start;

will result in no constructor being called for iter,
Whereas:

  const C::const_iterator start = my_list.begin();
  C::const_iterator iter;
  iter = start;

results in the correct code. Also:

  const C::const_iterator start = my_list.begin();
  C::const_iterator iter(start);

results in no copy constructor being called either.
In all cases compiling without optimisation, or with
-O2 results in the same behaviour.

My gcc version is:

Reading specs from /usr/local/gcc-3.0.2/lib/gcc-lib/i686-pc-linux-gnu/3.0.2/specs
Configured with: ../configure --prefix=/usr/local/gcc-3.0.2 --enable-shared --enable-threads --enable-languages=c,c++,java
Thread model: posix
gcc version 3.0.2

If this (or something similar) is known, I wont file a bug report.
If it isn't (and it still occurs in 3.0.4, which I am downloading
right now), I will go ahead. I can't use 3.1 for now as it will
require some work to fix my code, but if this is a known problem
that is fixed in 3.1 let me know and I'll put aside some time for
a code conversion.

Thanks for your time,

/Mike

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

* Re: Missing constructor call...
  2002-07-15 17:27 Missing constructor call Mike Harrold
@ 2002-07-15 17:55 ` Gokhan Kisacikoglu
  2002-07-15 18:55   ` Mike Harrold
  0 siblings, 1 reply; 3+ messages in thread
From: Gokhan Kisacikoglu @ 2002-07-15 17:55 UTC (permalink / raw)
  To: Mike Harrold; +Cc: gcc-help


> If I have a class representing iterators, then under
> certain circumstances:

Is there anyway you can describe a bit more these certain circumstances
to determine whether this is really a bug in your code or in the gcc? It
is really suspicious that this is working in some instances and not in
others...

Thanks,
Gokhan


> 
>   const C::const_iterator start = my_list.begin();
>   C::const_iterator iter = start;
> 
> will result in no constructor being called for iter,
> Whereas:
> 
>   const C::const_iterator start = my_list.begin();
>   C::const_iterator iter;
>   iter = start;
> 
> results in the correct code. Also:
> 
>   const C::const_iterator start = my_list.begin();
>   C::const_iterator iter(start);
>

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

* Re: Missing constructor call...
  2002-07-15 17:55 ` Gokhan Kisacikoglu
@ 2002-07-15 18:55   ` Mike Harrold
  0 siblings, 0 replies; 3+ messages in thread
From: Mike Harrold @ 2002-07-15 18:55 UTC (permalink / raw)
  To: kisa; +Cc: Mike Harrold, gcc-help

> 
> 
> > If I have a class representing iterators, then under
> > certain circumstances:
> 
> Is there anyway you can describe a bit more these certain circumstances
> to determine whether this is really a bug in your code or in the gcc? It
> is really suspicious that this is working in some instances and not in
> others...
> 
> Thanks,
> Gokhan

Sorry, I should have been a little more specific. The certain
circumstances are somewhat unknown. What I do know is that I
have not yet been able to create a small testcase that shows
the problem. I also know that in some situations with the same
code usage, albeit in a different place, that the correct
behaviour occurs.

When iterating through a list, I use the following style:

  const class::const_iterator start = list.begin();
  const class::const_iterator finish = list.end();
  for (class::const_iterator iter = start; iter != finish; ++iter)
    ...

This is how I initially discovered the problem. I resolved it
down to the construction/initialisation problem by testing 
various things.

If I can construct a small testcase I'll post it (assuming that
the problem is not fixed in 3.0.4 which I am compiling now).

/Mike

> >   const C::const_iterator start = my_list.begin();
> >   C::const_iterator iter = start;
> > 
> > will result in no constructor being called for iter,
> > Whereas:
> > 
> >   const C::const_iterator start = my_list.begin();
> >   C::const_iterator iter;
> >   iter = start;
> > 
> > results in the correct code. Also:
> > 
> >   const C::const_iterator start = my_list.begin();
> >   C::const_iterator iter(start);

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

end of thread, other threads:[~2002-07-16  1:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-15 17:27 Missing constructor call Mike Harrold
2002-07-15 17:55 ` Gokhan Kisacikoglu
2002-07-15 18:55   ` Mike Harrold

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).