﻿id	summary	reporter	owner	description	type	status	priority	component	version	resolution	keywords	cc
287	Incorrect Typeof on Array Index	ajbeach		"This is a follow up to #286. They exact relation between them is unclear. I discovered them on the same line of code, I believe they were just ""hidden"" until now in the same way.

Here is the reproduction:
{{{
#define SIZE 2
char array[SIZE];

// Passes
_Static_assert(SIZE == sizeof(array) / sizeof(array[0]), ""0a"");

// Fails 
_Static_assert(SIZE == sizeof(typeof(array)) / sizeof(typeof(array[0])), ""1a"");

// Fails (second typeof is the one) 
_Static_assert(SIZE == sizeof(array) / sizeof(typeof(array[0])), ""2a"");

// Passes 
_Static_assert(SIZE == sizeof(typeof(array)) / sizeof(array[0]), ""3a"");
}}}

Having looked at the post translation cases, the `sizeof` on `array[0]` does nothing (other than resolving the expression) while adding the `typeof` reduces it to the resolved type. If the resolved type was correct, this would make no difference, but it is resolved incorrectly to be a pointer to the element type instead of the element type itself.

I believe that making `typeof` resolve correctly is the only full solution, but delaying the reduction to C will solve this case.

Oh, and here are some extra cases that help show exactly what the error is.
{{{
// Here are just the same patterns (0c, 1b, 2b, 3c fail)
_Static_assert(sizeof(char) == sizeof(array[0]), ""0b"");
_Static_assert(sizeof(void *) == sizeof(array[0]), ""0c"");
_Static_assert(sizeof(typeof(char)) == sizeof(typeof(array[0])), ""1b"");
_Static_assert(sizeof(typeof(void *)) == sizeof(typeof(array[0])), ""1c"");
_Static_assert(sizeof(char) == sizeof(typeof(array[0])), ""2b"");
_Static_assert(sizeof(void *) == sizeof(typeof(array[0])), ""2c"");
_Static_assert(sizeof(typeof(char)) == sizeof(array[0]), ""3b"");
_Static_assert(sizeof(typeof(void *)) == sizeof(array[0]), ""3c"");
}}}"	defect	closed	major	cfa-cc	1.0	fixed		
