[antlr-interest] [PATCH] ANTLR C++ RefAST operator=

aliguori123 ajl13 at bellatlantic.net
Fri Feb 1 17:48:10 PST 2002


GDB + C++ + -O2 == Major Headache...

I am still not sure exactly the depth of this and if I was just doing
some very bad things but I ran into a few infinite loops because the
operator='s are not checking for self assignment.  

While I'm not sure if I ran into this because my code was horribly
messed up, I know that reference counted objects have to check for
self assignment :)  I've made that mistake all too often.

Enclosed is a patch against 2.7.1 (the problem still exists in
2.7.2a2).

I am not sure how to submit patchs/bug reports or if there is a
separate maintainer of the C++ lib so I apologize if this is the wrong
place for this.

I am really loving ANTLR though!  Even though I spent a few hours
tracking down some nasty bugs, I more than saved it with the tree
walkers.

Regards,
Anthony Liguori

<-- BEGIN PATCH -->
2002-02-01 20:40 diff -rl antlr-2.7.1/lib/cpp/antlr/ASTRefCount.hpp
antlr-2.7.1-al/lib/cpp/antlr/ASTRefCount.hpp Page 1


51a52
>         static bool compareRef(const ASTRef* lhs, const AST* rhs);
78a80
>                 if (ASTRef::compareRef(ref, other)) return *this;
85a88
> 	        if (this == &other) return *this;
104a108,109
> 
> 
 2002-02-01 20:40 diff -rl antlr-2.7.1/lib/cpp/antlr/RefCount.hpp
antlr-2.7.1-al/lib/cpp/antlr/RefCount.hpp Page 1


70a71
> 	        if (this == &other) return *this;
 2002-02-01 20:40 diff -rl antlr-2.7.1/lib/cpp/src/ASTRefCount.cpp
antlr-2.7.1-al/lib/cpp/src/ASTRefCount.cpp Page 1


60a61,65
> bool ASTRef::compareRef(const ASTRef* lhs, const AST* rhs)
> {
>   return (lhs == (rhs ? rhs->ref : 0));
> }
>

<-- END PATCH -->



 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list