[Bug c++/14459] [3.4/3.5? regression] Assignment of cast of __typeof__ of function pointer not treated as function pointer anymore.
bangerth at dealii dot org
gcc-bugzilla@gcc.gnu.org
Sat Mar 6 21:51:00 GMT 2004
------- Additional Comments From bangerth at dealii dot org 2004-03-06 21:51 -------
Confirmed, though I believe this may be a parser problem. Take this example instead:
--------------------
void g(...);
void foo(int)
{
g((__typeof__(&foo))(foo));
g(__typeof__(&foo)(foo));
}
------------------
where we get:
tmp/g> ~/bin/gcc-3.3/bin/c++ -c x.cc
tmp/g> /workspace/bangerth/build-gcc-3.4/gcc-install/bin/c++ -c x.cc
x.cc: In function `void foo(int)':
x.cc:5: error: invalid conversion from `void (*)(int)' to `int'
x.cc:5: error: expected primary-expression before "typeof"
So the first line succeeds because the parser sees an argument to g() of the form
(type)(value), i.e. a C-style type cast. In the second line, we have a C++-style initializer
of the form type(value). The parser gets this wrong, or at least differently than before.
I'm not sure whether we have any specification that says how __typeof__ is supposed to work.
I could imagine, it works as
__typeof__ expr
and the parser tries to take
expr = &foo(foo)
and gets confused because the address of foo is not the right type of argument to call
foo() and take the address of the return value. This is supported by looking at this testcase:
--------------------
void g(...);
void foo()
{
g(__typeof__(&foo)(foo));
}
-------------------
where we get
x.cc: In function `void foo()':
x.cc:4: error: too many arguments to function
x.cc:4: error: expected primary-expression before "typeof"
The first line indicates that we try to call foo() with an argument, which shouldn't work since
foo doesn't take any arguments.
Do we have someone who can tell us how __typeof__ is supposed to work?
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |3.4.0
Known to work| |3.3.3
Summary|Regression 3.4 : Assignment |[3.4/3.5? regression]
|of cast of __typeof__ of |Assignment of cast of
|function pointer not treated|__typeof__ of function
|as function pointer anymore.|pointer not treated as
| |function pointer anymore.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14459
More information about the Gcc-bugs
mailing list