------- Comment #2 from pavel dot petrovic at gmail dot com 2006-04-03 16:03 ------- (In reply to comment #1) > types are not expressions though.
sure, but I wouldn't mind that, the compiler complains about expression, not about type. isn't typecasting an expression after all? > It is not incorrect but just misleading. What you mean by incorrect and what you mean by misleading? The error message produced by the compiler is definitely not correct. say you insert this line before line 17: char *x = (char *)malloc(sizeof(t) * t->a); you get the following: bug.cpp:17: error: expected primary-expression before 'char' bug.cpp:17: error: expected `)' before 'char' bug.cpp:18: error: expected primary-expression before '*' token bug.cpp:18: error: expected primary-expression before ')' token bug.cpp:18: error: expected `;' before 'malloc' why does the compiler reports problem "before 'char'", if the problem is far at the other end of the same line? but this also shows that it is not a problem of the same identifier at the same line occuring twice - although in that case, we also get the ';' error, which we do not get in case of (char *)...? anyhow, doesn't the behavior indicate some mix up...? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26997