public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56095] New: Crash casting function pointer as non-type template argument
@ 2013-01-24  5:23 spoo at zarbosoft dot com
  2013-01-24  6:39 ` [Bug c++/56095] " spoo at zarbosoft dot com
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: spoo at zarbosoft dot com @ 2013-01-24  5:23 UTC (permalink / raw)
  To: gcc-bugs


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-03-17  2:34 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-24  5:23 [Bug c++/56095] New: Crash casting function pointer as non-type template argument spoo at zarbosoft dot com
2013-01-24  6:39 ` [Bug c++/56095] " spoo at zarbosoft dot com
2013-01-24 11:56 ` daniel.kruegler at googlemail dot com
2013-01-24 12:02 ` redi at gcc dot gnu.org
2013-01-24 12:08 ` daniel.kruegler at googlemail dot com
2013-01-24 12:11 ` [Bug c++/56095] [4.6/4.7/4.8 Regression] " jakub at gcc dot gnu.org
2013-01-24 12:12 ` jakub at gcc dot gnu.org
2013-01-24 12:14 ` redi at gcc dot gnu.org
2013-01-25 20:01 ` jason at gcc dot gnu.org
2013-01-25 20:05 ` [Bug c++/56095] [4.6/4.7 " jakub at gcc dot gnu.org
2013-01-25 20:20 ` jason at gcc dot gnu.org
2013-03-17  2:34 ` jason at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).