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 target/17653] New: different parameter passing methods not checked on function pointer assignments


In order to help the developer, checks for attribute consistency respective
regparm, stdcall, or fastcall (for i386, for other architectures this would
apply similarly if they support attributes of similar functionality) should be
added. Identically, this would be good for architecture-independent function
attributes like pure. Specifically, the example below should not compile without
any diagnostic:

typedef __attribute__((__regparm__(0))) int noregs_t(int, int);
typedef __attribute__((__regparm__(1))) int onereg_t(int, int);
typedef __attribute__((__regparm__(2))) int tworegs_t(int, int);

noregs_t noregs;
onereg_t onereg;
tworegs_t tworegs;

noregs_t*noregs_a[] = {noregs, onereg, tworegs};
onereg_t*onereg_a[] = {noregs, onereg, tworegs};
tworegs_t*tworegs_a[] = {noregs, onereg, tworegs};

int test(int i, int x, int y) {
	return noregs_a[i](x, y) * -onereg_a[i](x, y) + tworegs_a[i](x, y);
}

-- 
           Summary: different parameter passing methods not checked on
                    function pointer assignments
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jbeulich at novell dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-suse-linux
  GCC host triplet: i686-suse-linux
GCC target triplet: i686-suse-linux


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


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