Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 364225 - NPE parsing delete expression containing templated function call
Summary: NPE parsing delete expression containing templated function call
Status: VERIFIED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: 8.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 8.0.2   Edit
Assignee: Markus Schorn CLA
QA Contact: Markus Schorn CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 364188
  Show dependency tree
 
Reported: 2011-11-19 14:15 EST by Marc-André Laperle CLA
Modified: 2012-01-22 11:44 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc-André Laperle CLA 2011-11-19 14:15:58 EST
Tested with 8.0.0, 8.0.1 and master. From bug 364188.

template <class T>
class TypeA{};

class TypeB{};

template <class T>
T * func() { return 0; }

int main()
{
    delete func<TypeA <TypeB> >(); // This line causes the NPE
}


If the expression is instead :
delete func<TypeB>();

then there is no NPE

java.lang.NullPointerException
	at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.qualifiedName(GNUCPPSourceParser.java:291)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.primaryExpression(GNUCPPSourceParser.java:1693)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.postfixExpression(GNUCPPSourceParser.java:1496)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.unaryExpression(GNUCPPSourceParser.java:1316)
	at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.castExpression(AbstractGNUSourceCodeParser.java:1264)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.deleteExpression(GNUCPPSourceParser.java:1090)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.unaryExpression(GNUCPPSourceParser.java:1263)
	at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.castExpression(AbstractGNUSourceCodeParser.java:1264)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.castExpressionForBinaryExpression(GNUCPPSourceParser.java:1016)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.expression(GNUCPPSourceParser.java:766)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.expression(GNUCPPSourceParser.java:737)
	at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.parseDeclarationOrExpressionStatement(AbstractGNUSourceCodeParser.java:1851)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.statement(GNUCPPSourceParser.java:4309)
	at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.compoundStatement(AbstractGNUSourceCodeParser.java:855)
	at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.functionBody(AbstractGNUSourceCodeParser.java:1452)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.functionBody(GNUCPPSourceParser.java:4522)
	at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.handleFunctionBody(AbstractGNUSourceCodeParser.java:1441)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.functionDefinition(GNUCPPSourceParser.java:2490)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.simpleDeclaration(GNUCPPSourceParser.java:2400)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser.declaration(GNUCPPSourceParser.java:2236)
	at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.declarationList(AbstractGNUSourceCodeParser.java:1345)
	at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.parseTranslationUnit(AbstractGNUSourceCodeParser.java:1283)
	at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.translationUnit(AbstractGNUSourceCodeParser.java:1278)
	at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.parse(AbstractGNUSourceCodeParser.java:650)
	at org.eclipse.cdt.core.dom.parser.AbstractCLikeLanguage.getASTTranslationUnit(AbstractCLikeLanguage.java:148)
	at org.eclipse.cdt.internal.core.model.TranslationUnit.getAST(TranslationUnit.java:809)
	at org.eclipse.cdt.internal.core.model.TranslationUnit.getAST(TranslationUnit.java:768)
	at org.eclipse.cdt.internal.core.model.ASTCache$1.run(ASTCache.java:342)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.cdt.internal.core.model.ASTCache.createAST(ASTCache.java:336)
	at org.eclipse.cdt.internal.core.model.ASTCache.getAST(ASTCache.java:170)
	at org.eclipse.cdt.internal.core.model.ASTCache.acquireSharedAST(ASTCache.java:256)
	at org.eclipse.cdt.internal.core.model.ASTCache.runOnAST(ASTCache.java:217)
	at org.eclipse.cdt.internal.ui.editor.ASTProvider.runOnAST(ASTProvider.java:347)
	at org.eclipse.cdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:168)
	at org.eclipse.cdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup$3.run(SelectionListenerWithASTManager.java:142)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Comment 1 Markus Schorn CLA 2011-11-29 07:09:18 EST
Added testcase and fix.
Comment 2 CDT Genie CLA 2011-11-29 07:23:02 EST
*** cdt git genie on behalf of Markus Schorn ***

    Bug 364225: NPE in template ambiguity handling in delete expression.

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=ad09f40af5ae2304f1030511e8b70b5f27946899
Comment 3 CDT Genie CLA 2011-11-29 07:23:03 EST
*** cdt git genie on behalf of Markus Schorn ***

    Bug 364225: NPE in template ambiguity handling in delete expression.

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=bc6ff322dc0bf7d1e9a29b8cb791bc932dfc070c
Comment 4 Marc-André Laperle CLA 2012-01-22 11:44:19 EST
Verified in 8.0.2 RC1.