[cfe-dev] Endless operator-> chain causing infinite loop

Karen Shaeffer shaeffer at neuralscape.com
Wed Oct 23 13:24:38 PDT 2013


On Wed, Oct 23, 2013 at 11:27:10AM -0700, Richard Smith wrote:
> On Wed, Oct 23, 2013 at 6:06 AM, Rahul Jain <1989.rahuljain at gmail.com>wrote:
> 
> > Hi Richard / Karen,
> >
> > Thanks for making things clearer.
> > Now how do we go about handling this sort of behavior?
> >
> > Do we throw an error message just like g++ does? Wont it be better to
> > print an error message instead of an infinite loop?
> >
> 
> We don't know the loop is infinite, but we should probably give up after
> some number of iterations.
> 
> 
> > Also if you could please elaborate a bit on how we can "limit the number
> > of times we go around the loop looking for an overloaded operator->
> > in Sema::
> > ActOnStartCXXMemberReference" ?
> >
> 
> Add a counter to the "while (BaseType->isRecordType())" loop. Bail out with
> a diagnostic if it hits the limit.
> 
> 
> > Thanks,
> > Rahul

Hi Rahul,

Just a couple comments. I think consideration should be given to implementing a
command line option to override  the limit. If some group knows what they are doing
and have the resources to support a higher limit, then the compiler ought not to
preclude them from doing so.

I did give all this some thought last evening. Interesting subject. One thing is the
gcc implementation is limiting a resource. And so there is no chance of unintended
side effects. In limiting the idiom, there could potentially be unintended side effects.
I'd make the limit as high as reasonably possible. And the commandline override seems
prudent.

enjoyed all the comments. food for thought.

thanks,
Karen
-- 
Karen Shaeffer                 Be aware: If you see an obstacle in your path,
Neuralscape Services           that obstacle is your path.        Zen proverb



More information about the cfe-dev mailing list