On Thu, Oct 23, 2014 at 05:59:32PM +0200, Peter Stuge wrote:
How come it has higher rank?
I don't have the spec, maybe it is stated explicitly there, but this blog post (it's on the internet so it MUST be true!) outlines rules based on the standard, and doesn't mention either size_t type.
#include <stdint.h> #include <sys/socket.h> #include <stdint.h>
int foo() { unsigned int foo = 1212323123123; size_t bla = 2;
typeof(foo - bla) k; k = 3; }
clang-3.4 -Xclang -ast-dump -fsyntax-only foo.c
`-FunctionDecl 0x9946300 </tmp/foo.c:5:1, line:12:1> foo 'int ()' `-CompoundStmt 0x9946588 <line:6:1, line:12:1> |-DeclStmt 0x99463c8 <line:7:2, col:34> | `-VarDecl 0x9946370 <col:2, col:21> foo 'unsigned int' | `-ImplicitCastExpr 0x99463b8 col:21 'unsigned int' <IntegralCast> | `-IntegerLiteral 0x99463a0 col:21 'long long' 1212323123123 |-DeclStmt 0x9946438 <line:8:2, col:16> | `-VarDecl 0x99463e0 <col:2, col:15> bla 'size_t':'unsigned int' | `-ImplicitCastExpr 0x9946428 col:15 'size_t':'unsigned int' <IntegralCast> | `-IntegerLiteral 0x9946410 col:15 'int' 2 |-DeclStmt 0x9946520 <line:10:2, col:21> | `-VarDecl 0x99464f0 <col:2, col:20> k 'typeof (foo - bla)':'unsigned int' `-BinaryOperator 0x9946570 <line:11:2, col:6> 'typeof (foo - bla)':'unsigned int' '=' |-DeclRefExpr 0x9946530 col:2 'typeof (foo - bla)':'unsigned int' lvalue Var 0x99464f0 'k' 'typeof (foo - bla)':'unsigned int' `-ImplicitCastExpr 0x9946560 col:6 'typeof (foo - bla)':'unsigned int' <IntegralCast> `-IntegerLiteral 0x9946548 col:6 'int' 3
If I read this correctly the type is 'unsigned int' with clang? An issue with my reading? Clang bug?
cheers holger