Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 368309 - CDT fails to evaluate sizeof expression
Summary: CDT fails to evaluate sizeof expression
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: 8.1.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 8.1.0   Edit
Assignee: Markus Schorn CLA
QA Contact: Markus Schorn CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-10 21:12 EST by Nathan Ridge CLA
Modified: 2012-02-29 13:21 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 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