with the following test program, gcc-4.0 doesn't emit the required function
canonicalization code (calls to __canonicalize_funcptr_for_compare) to do the
comparison when optimization is enabled.

[EMAIL PROTECTED]:/tmp/dl$ gcc-3.3 -D_GNU_SOURCE -O2 -o default default.c -ldl;
./default; echo $?
0

[EMAIL PROTECTED]:/tmp/dl$ gcc-4.0 -D_GNU_SOURCE -O2 -o default default.c -ldl;
./default; echo $?
1


#include <dlfcn.h>
#include <stdio.h>

int
main (int argc, char *argv[])
{
  void *p;

  /* Find function `main'.  */
  p = dlsym (RTLD_DEFAULT, "main");
  if (p == NULL)
    return -1;
  else if ((int (*)(int, char **))p != main)
    return 1;
  else
    return 0;
 }

-- 
           Summary: [4.0 regression] Wrong code for function pointer
                    comparision during optimization
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tausq at debian dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: hppa-unknown-linux
  GCC host triplet: hppa-unknown-linux
GCC target triplet: hppa-unknown-linux


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

Reply via email to