[LLVMbugs] [Bug 6030] New: confusing warning from clang re. incompatible pointer types

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Jan 13 09:51:26 PST 2010


http://llvm.org/bugs/show_bug.cgi?id=6030

           Summary: confusing warning from clang re. incompatible pointer
                    types
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: regehr at cs.utah.edu
                CC: llvmbugs at cs.uiuc.edu


The second warning effectively says "X is wrong, expected X".  Obviously the
code is bogus but the warning could be better!


regehr at john-home:~/volatile/bugs/tmp256$ clang small.c -c
small.c:5:25: warning: declaration of 'struct archive_read' will not be visible
      outside of this function
  int (*finish) (struct archive_read *);
                        ^
small.c:18:29: warning: incompatible pointer types assigning 'int (*)(struct
      archive_read *)', expected 'int (*)(struct archive_read *)'
  (a->decompressor)->finish = &archive_decompressor_none_finish;
                            ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 diagnostics generated.
regehr at john-home:~/volatile/bugs/tmp256$ cat small.c
typedef unsigned long size_t;

struct decompressor_t
{
  int (*finish) (struct archive_read *);
};

struct archive_read
{
  struct decompressor_t *decompressor;
};

int archive_decompressor_none_finish (struct archive_read *a);

int archive_decompressor_none_init (struct archive_read *a, void const *buff,
                                    size_t n)
{
  (a->decompressor)->finish = &archive_decompressor_none_finish;
  return 0;
}
regehr at john-home:~/volatile/bugs/tmp256$ clang -v
clang version 1.1 (trunk 93238)
Target: i386-pc-linux-gnu
Thread model: posix


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list