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++/56095] New: Crash casting function pointer as non-type template argument


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

             Bug #: 56095
           Summary: Crash casting function pointer as non-type template
                    argument
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: spoo@zarbosoft.com


g++ crashes when trying to cast a function pointer to another function pointer
as a non-type template argument.  I get a strange error in 4.6.3, and 4.7.2
segfaults.

Platform: Ubuntu 12.04.1 LTS
uname -a: Linux cerberus 3.2.0-35-generic #55-Ubuntu SMP Wed Dec 5 17:42:16 UTC
2012 x86_64 x86_64 x86_64 GNU/Linux

Code (c.cxx):
int *a(void) { return 0; }
typedef void (*IntermediarySignature)(void);
template <IntermediarySignature b> void z(void) {}

int main(int argc, char **argv)
{
    z<(IntermediarySignature)a>();
    z<reinterpret_cast<IntermediarySignature>(a)>();
    return 0;
}

4.7 output:
> g++-4.7 -std=c++11 c.cxx 
c.cxx: In function âint main(int, char**)â:
c.cxx:7:30: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.7/README.Bugs> for instructions.
Preprocessed source stored into /tmp/cc8vdZAa.out file, please attach this to
your bugreport.

If line 7 is commented out (the c-style cast), there's a segfault on line 8.

4.6 output:
> g++ -std=c++0x c.cxx 
c.cxx: In function âint main(int, char**)â:
c.cxx:7:30: error: â(IntermediarySignature)aâ is not a valid template argument
for type âvoid (*)()â because function â#ânop_exprâ not supported by
dump_decl#<declaration error>â has not external linkage
c.cxx:7:30: error: no matching function for call to âz()â
c.cxx:7:30: note: candidate is:
c.cxx:3:41: note: template<void (* b)()> void z()
c.cxx:8:48: error: â(IntermediarySignature)aâ is not a valid template argument
for type âvoid (*)()â because function â#ânop_exprâ not supported by
dump_decl#<declaration error>â has not external linkage
c.cxx:8:48: error: no matching function for call to âz()â
c.cxx:8:48: note: candidate is:
c.cxx:3:41: note: template<void (* b)()> void z()


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