This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/14459] New: Regression 3.4 : Assignment of cast of __typeof__ of function pointer not treated as function pointer anymore.


The following compiles with 3.3.3, it doesn't compile with 3.4.

~/c++/g++.bugs/bug18>cat test.cc
// Deliberate errors so we can see what the type of 'T' is.
template<typename T> float f1(T) { return T(); }
template<typename T> float f2(T) { return T(); }
template<typename T> float f3(T) { return T(); }

static int (*S_main)(int, char**, char**);

int main(int, char**, char**)
{
  // This works:
  f1((__typeof__(S_main))(main));

  // This works:
  typedef __typeof__(S_main) type_of_S_main;
  f2(type_of_S_main(main));

  // This doesn't anymore:
  f3(__typeof__(S_main)(main));
}


~/c++/g++.bugs/bug18>g++-3.3.3 -Wall -c test.cc
test.cc: In function `float f1(T) [with T = int (*)(int, char**, char**)]':
test.cc:11:   instantiated from here
test.cc:2: error: cannot convert `int (*)(int, char**, char**)' to `float' in
   return
test.cc: In function `float f2(T) [with T = int (*)(int, char**, char**)]':
test.cc:15:   instantiated from here
test.cc:3: error: cannot convert `int (*)(int, char**, char**)' to `float' in
   return
test.cc: In function `float f3(T) [with T = int (*)(int, char**, char**)]':
test.cc:18:   instantiated from here
test.cc:4: error: cannot convert `int (*)(int, char**, char**)' to `float' in
   return


~/c++/g++.bugs/bug18>g++-cvs-3.4 -Wall -c test.cc
test.cc: In function `int main(int, char**, char**)':
test.cc:18: error: invalid conversion from `int (*)(int, char**, char**)' to `int'
test.cc:18: error: too few arguments to function
test.cc:18: error: expected primary-expression before "typeof"
test.cc: In function `float f1(T) [with T = int (*)(int, char**, char**)]':
test.cc:11:   instantiated from here
test.cc:2: error: cannot convert `int (*)(int, char**, char**)' to `float' in return
test.cc: In function `float f2(T) [with T = int (*)(int, char**, char**)]':
test.cc:15:   instantiated from here
test.cc:3: error: cannot convert `int (*)(int, char**, char**)' to `float' in return


For some reason 3.4 thinks that  __typeof__(S_main)(main) has
type 'int' thus.

-- 
           Summary: Regression 3.4 : Assignment of cast of __typeof__ of
                    function pointer not treated as function pointer
                    anymore.
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: carlo at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14459


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]