Bug 72546 - [Templates] Template Parameters in expressions.
Summary: [Templates] Template Parameters in expressions.
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 2.0.1   Edit
Assignee: Andrew Niefer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 60307
Blocks:
  Show dependency tree
 
Reported: 2004-08-24 16:07 EDT by Keith W. Campbell CLA
Modified: 2004-08-25 13:04 EDT (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 Keith W. Campbell CLA 2004-08-24 16:07:41 EDT
The indexer (among others) encounter a NullPointerException
on the code below. (cdt-2.0.1-I200408201009).

template <class T>
  int add(T * x, T * y)
  {
    return x->value + y->value;
  };

Thread [C/C++ Indexer] (Suspended (exception NullPointerException))
	CompleteParseASTFactory.usualArithmeticConversions(IASTScope, 
ITypeInfo, ITypeInfo) line: 1360
	CompleteParseASTFactory.getExpressionResultType(IASTScope, 
IASTExpression$Kind, IASTExpression, IASTExpression, IASTExpression, 
IASTTypeId, char[], ISymbol) line: 1731
	CompleteParseASTFactory.createExpression(IASTScope, 
IASTExpression$Kind, IASTExpression, IASTExpression, IASTExpression, 
IASTTypeId, ITokenDuple, char[], IASTExpression$IASTNewExpressionDescriptor) 
line: 1100
	CompleteParser(ExpressionParser).additiveExpression(IASTScope, 
IASTCompletionNode$CompletionKind, KeywordSetKey) line: 1362
	CompleteParser(ExpressionParser).shiftExpression(IASTScope, 
IASTCompletionNode$CompletionKind, KeywordSetKey) line: 1311
	CompleteParser(ExpressionParser).relationalExpression(IASTScope, 
IASTCompletionNode$CompletionKind, KeywordSetKey) line: 1238
	CompleteParser(ExpressionParser).equalityExpression(IASTScope, 
IASTCompletionNode$CompletionKind, KeywordSetKey) line: 1196
	CompleteParser(ExpressionParser).andExpression(IASTScope, 
IASTCompletionNode$CompletionKind, KeywordSetKey) line: 1144
	CompleteParser(ExpressionParser).exclusiveOrExpression(IASTScope, 
IASTCompletionNode$CompletionKind, KeywordSetKey) line: 1111
	CompleteParser(ExpressionParser).inclusiveOrExpression(IASTScope, 
IASTCompletionNode$CompletionKind, KeywordSetKey) line: 1078
	CompleteParser(ExpressionParser).logicalAndExpression(IASTScope, 
IASTCompletionNode$CompletionKind, KeywordSetKey) line: 1045
	CompleteParser(ExpressionParser).logicalOrExpression(IASTScope, 
IASTCompletionNode$CompletionKind, KeywordSetKey) line: 1013
	CompleteParser(ExpressionParser).conditionalExpression(IASTScope, 
IASTCompletionNode$CompletionKind, KeywordSetKey) line: 979
	CompleteParser(ExpressionParser).assignmentExpression(IASTScope, 
IASTCompletionNode$CompletionKind, KeywordSetKey) line: 881
	CompleteParser(ExpressionParser).expression(IASTScope, 
IASTCompletionNode$CompletionKind, KeywordSetKey) line: 840
	CompleteParser(Parser).statement(IASTCodeScope) line: 3150
	CompleteParser(Parser).compoundStatement(IASTScope, boolean) line: 3333
	CompleteParser(Parser).functionBody(IASTScope) line: 3027
	CompleteParser.handleFunctionBody(IASTScope) line: 45
	CompleteParser(Parser).simpleDeclaration(SimpleDeclarationStrategy, 
IASTScope, IASTTemplate, IASTCompletionNode$CompletionKind, boolean, 
KeywordSetKey) line: 1292
	CompleteParser(Parser).simpleDeclarationStrategyUnion(IASTScope, 
IASTTemplate, IASTCompletionNode$CompletionKind, KeywordSetKey) line: 924
	CompleteParser(Parser).declaration(IASTScope, IASTTemplate, 
IASTCompletionNode$CompletionKind, KeywordSetKey) line: 900
	CompleteParser(Parser).templateDeclaration(IASTScope) line: 616
	CompleteParser(Parser).declaration(IASTScope, IASTTemplate, 
IASTCompletionNode$CompletionKind, KeywordSetKey) line: 891
	CompleteParser(Parser).translationUnit() line: 187
	CompleteParser(Parser).parse() line: 140
	SourceIndexer.indexFile(IDocument) line: 128
	SourceIndexer(AbstractIndexer).index(IDocument, IIndexerOutput) line: 
500
	Index.add(IDocument, IIndexer) line: 110
	AddCompilationUnitToIndex.indexDocument(IIndex) line: 29
	AddCompilationUnitToIndex(AddFileToIndex).execute(IProgressMonitor) 
line: 55
	IndexManager(JobManager).run() line: 471
	Thread.run() line: 534
Comment 1 John Camelon CLA 2004-08-25 09:06:13 EDT
Andrew, please look into this today if you can.
If it cannot be fixed, pls provide a workaround.  
Comment 2 Andrew Niefer CLA 2004-08-25 10:33:28 EDT
The best I will be able to do for this in 2.0.1 is to avoid the null pointer.  
Successfully parsing this will be harder, this is the same problem as 60307.
Comment 3 Andrew Niefer CLA 2004-08-25 11:44:46 EDT
the NPE has been fixed in 2.0.1, it appears to have been fixed in the head at 
some other time.

I'm dropping the severity/priority and leaving this open so I something 
regarding template parameters in expressions to go along with 60307.
Comment 4 John Camelon CLA 2004-08-25 11:55:54 EDT
Andrew, pls close this defect and raise another shadow defect if required.
Thanks
Comment 5 Andrew Niefer CLA 2004-08-25 13:04:37 EDT
I ammend my piratical ways and return the highjacked defect.