[Bug c++/45492] New: G++ permits function-to-data pointer conversions with __extension__ in functions, but not function templates
jimb at red-bean dot com
gcc-bugzilla@gcc.gnu.org
Thu Sep 2 00:29:00 GMT 2010
With trunk G++:
$ ~/gcc/bin/g++ --version
g++ (GCC) 4.6.0 20100901 (experimental)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ cat fdc.cc
extern void cf();
// no warning
void *f() { return __extension__ (void *) cf; }
// warning:
// ISO C++ forbids casting between pointer-to-function and pointer-to-object
template<bool flag>
void *ft() { return __extension__ (void *) cf; }
template void *ft<true>();
$ LD_LIBRARY_PATH=$HOME/gcc/lib ~/gcc/bin/g++ -Wall -pedantic -c fdc.cc
fdc.cc: In function Âvoid* ft() [with bool flag = true]Â:
fdc.cc:11:25: instantiated from here
fdc.cc:9:44: warning: ISO C++ forbids casting between pointer-to-function and
pointer-to-object [enabled by default]
I would expect G++ to either complain about both casts, or neither; whether the
code appears in a function template shouldn't matter.
--
Summary: G++ permits function-to-data pointer conversions with
__extension__ in functions, but not function templates
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jimb at red-bean dot com
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45492
More information about the Gcc-bugs
mailing list