http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46170
Summary: g++ wrongly rejects pointer-to-member in template arguments Product: gcc Version: 4.4.4 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: f...@csl.cornell.edu The following reduced test case is wrongly rejected by g++-4.4 and g++-4.5: ============ test case: reduce.ii ================= namespace util { struct option_value { }; template <class T> struct options_map_impl { typedef T options_struct_type; typedef bool (*opt_func)(const option_value&, options_struct_type&); template <class V, V K> static bool set_member_constant(const option_value&, options_struct_type&, V options_struct_type::*); template <class V, V options_struct_type::*mem, V K> static bool set_member_constant(const option_value& opt, options_struct_type& t) { return set_member_constant<V,K>(opt, t, mem); } }; } struct cflat_options { bool show_precharges; }; typedef util::options_map_impl<cflat_options> options_map_impl_type; class register_options_modifier { typedef options_map_impl_type::opt_func modifier_type; public: register_options_modifier(); register_options_modifier(const char* Mode, const modifier_type COM, const char* h); }; static const register_options_modifier cflat_opt_mod_show_precharges("precharges", &options_map_impl_type::set_member_constant<bool, &cflat_options::show_precharges, true>, "show precharge expressions"), cflat_opt_mod_no_show_precharges("no-" "precharges", &options_map_impl_type::set_member_constant<bool, &cflat_options::show_precharges, false>, "hide precharge expressions"); =========== end test case =============== delta-reduced using: #!/bin/sh -e # reduce.sh CXXFLAGS="-ansi -Woverloaded-virtual -W -Wextra -Wall -Wundef -Wshadow -Wno-unused-parameter -Wpointer-arith -Wcast-qual -Wcast-align -Wconversion -Werror -Wno-conversion -Wno-long-long" # must pass g++-4.2 first g++ $CXXFLAGS -c -o reduce.o reduce.ii g++-4 -pipe -g -O2 $CXXFLAGS -x c++ reduce.ii -o reduce.o 2> reduce.err || : grep -q "not a valid template argument" reduce.err # exactly 4 lines of errors el=`wc -l reduce.err | awk '{print $1;}'` test $el -eq 4 ============================================ diagnostic: reduce.ii: In static member function 'static bool util::options_map_impl<T>::set_member_constant(const util::option_value&, T&) [with V = bool, V T::* mem = &cflat_options::show_precharges, V K = true, T = cflat_options]': reduce.ii:22: instantiated from here reduce.ii:9: error: 'true' is not a valid template argument for type 'bool cflat_options::*' reduce.ii:9: error: it must be a pointer-to-member of the form `&X::Y' ============================================ it pass g++-4.2 and fails g++-4.4, g++-4.5: f...@fangbook 163> g++ -v Using built-in specs. Target: i686-apple-darwin10 Configured with: /var/tmp/gcc/gcc-5664~105/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1 Thread model: posix gcc version 4.2.1 (Apple Inc. build 5664) f...@fangbook 164> g++-4 -v Using built-in specs. Target: i386-apple-darwin10.4.0 Configured with: ../gcc-4.4.4/configure --prefix=/sw --prefix=/sw/lib/gcc4.4 --mandir=/sw/share/man --infodir=/sw/lib/gcc4.4/info --enable-languages=c,c++,fortran,objc,obj-c++,java --with-gmp=/sw --with-libiconv-prefix=/sw --with-ppl=/sw --with-cloog=/sw --with-mpc=/sw --with-system-zlib --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.4 Thread model: posix gcc version 4.4.4 (GCC) (for 4.5) g++-4 -v Using built-in specs. COLLECT_GCC=g++-4 COLLECT_LTO_WRAPPER=/Volumes/MacSpare/sw/lib/gcc4.5/bin/../libexec/gcc/i386-apple-darwin10.4.0/4.5.0/lto-wrapper Target: i386-apple-darwin10.4.0 Configured with: ../gcc-4.5.0/configure --prefix=/sw --prefix=/sw/lib/gcc4.5 --mandir=/sw/share/man --infodir=/sw/lib/gcc4.5/info --enable-languages=c,c++,fortran,objc,obj-c++,java --with-gmp=/sw --with-libiconv-prefix=/sw --with-ppl=/sw --with-cloog=/sw --with-mpc=/sw --with-system-zlib --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.5 Thread model: posix gcc version 4.5.0 (GCC) =================================== keywords: rejects-valid, diagnostic known-to-work: 4.2.1 known-to-fail: 4.4.4 4.5.0 This also used to work on 4.4.2, so it might be a branch regression.