Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 368309

Summary: CDT fails to evaluate sizeof expression
Product: [Tools] CDT Reporter: Nathan Ridge <zeratul976>
Component: cdt-parserAssignee: Markus Schorn <mschorn.eclipse>
Status: RESOLVED FIXED QA Contact: Markus Schorn <mschorn.eclipse>
Severity: normal    
Priority: P3 CC: cdtdoug
Version: 8.1.0   
Target Milestone: 8.1.0   
Hardware: All   
OS: All   
Whiteboard:

Description Nathan Ridge CLA 2012-01-10 21:12:06 EST
struct two { char x[2]; };

two check(...);
char check(int);

template <int> struct foo {};
template <> struct foo<1> { typedef int type; };

typedef foo<sizeof(check(0))>::type t;  // ERROR HERE


The error at the indicated line is: "Type 'foo<sizeof(check(0))>::type' could not be resolved"

It seems CDT is unable to evaluate sizeof(check(0)) correctly (or at all) and therefore doesn't know to look at the specialization.
Comment 1 Markus Schorn CLA 2012-01-11 07:49:16 EST
Evaluation of sizeof expressions has been implemented. There is a typo though, when the calculation is started for sizeof expressions with an unary expression as the argument.

Added testcase and fix.
Comment 2 CDT Genie CLA 2012-02-29 13:21:15 EST
*** cdt git genie on behalf of Markus Schorn ***

    Bug 368309: Value for sizeof expression

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=8aef9f4f9d9cf3ddd82daacd6d900d6e853d7930