| Summary: | Wrong type deduced for `sizeof` | ||
|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Tomasz Wesolowski <kosashi> |
| Component: | cdt-parser | Assignee: | Markus Schorn <mschorn.eclipse> |
| Status: | RESOLVED FIXED | QA Contact: | Markus Schorn <mschorn.eclipse> |
| Severity: | normal | ||
| Priority: | P3 | CC: | cdtdoug |
| Version: | 8.0 | ||
| Target Milestone: | 8.0.2 | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
Added testcase and fix. *** cdt git genie on behalf of Markus Schorn ***
Bug 355052: Type of sizeof expression.
[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=0e70cab1786e1e7902164e6f25e3735a3109b092
*** cdt git genie on behalf of Markus Schorn ***
Bug 355052: Type of sizeof expression.
[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=a0b81bac32fec837d38ec3122c42c21086fa8097
|
Case 1 (C++): #include <cstddef> void a() { typedef float size_t; sizeof(10); // wrong - getExpressionType returns float sizeof(int); // wrong - getExpressionType returns float } Case 2(C): #include <stddef.h> void foo() { sizeof(float); // correct sizeof(1.0); // wrong - getExpressionType returns double } For case 1, see: org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor.get_SIZE_T(IASTNode) (should only check global scope, I think?) For case 2, see: org.eclipse.cdt.internal.core.dom.parser.c.CASTUnaryExpression.getExpressionType() (doesn't handle some operators like sizeof)