[LLVMbugs] [Bug 11684] New: Syntactically illegal pointer-to-function type accepted

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Jan 1 06:32:22 PST 2012


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

             Bug #: 11684
           Summary: Syntactically illegal pointer-to-function type
                    accepted
           Product: clang
           Version: 3.0
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: ggreif at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Compile this code with clang:

------------------------------------------------------
template <typename RETURN, class RECEIVER, typename ARG1>
struct gauge_member_cfun
{
  typedef RETURN (*ref)(const RECEIVER&, ARG1) const;

  template <RETURN (RECEIVER::*MEMBER_FUN)(ARG1) const>
  struct regauge2
  {
    static RETURN ref(const RECEIVER& r, ARG1 a1) { return (r.*MEMBER_FUN)(a1);
}
  };

  template <RETURN (RECEIVER::*MEMBER_FUN)(ARG1) const>
  ref regauge(void) const;
};

template <typename RETURN, class RECEIVER, typename ARG1>
gauge_member_cfun<RETURN, RECEIVER, ARG1> gauge(RETURN (RECEIVER::*)(ARG1)
const);


struct Foo
{
  char* foo1c(int) const;
};

void gaugers__HS(void)
{
  gauge(&Foo::foo1c).regauge<&Foo::foo1c>();
}
------------------------------------------------------

It compiles without errors. But line 4

> typedef RETURN (*ref)(const RECEIVER&, ARG1) const;

is syntactically illegal. There can be no 'const' or 'volatile' specifier on
function pointers. So clang should reject this code, just like G++:

> gauge.cpp:4: error: ‘const’ and ‘volatile’ function specifiers on ‘ref’ invalid in type declaration

-- 
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