public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/62063] New: g++ disregards template specialization and skips try/catch blocks
@ 2014-08-08 14:10 ferenc.geczi at ericsson dot com
  2014-08-08 14:20 ` [Bug c++/62063] " redi at gcc dot gnu.org
  2014-09-17 16:15 ` paolo.carlini at oracle dot com
  0 siblings, 2 replies; 3+ messages in thread
From: ferenc.geczi at ericsson dot com @ 2014-08-08 14:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62063

            Bug ID: 62063
           Summary: g++ disregards template specialization and skips
                    try/catch blocks
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ferenc.geczi at ericsson dot com

Created attachment 33276
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33276&action=edit
Source code for reproducing the reported issue

g++ disregards that template specialization might happen in a different
compilation unit. 

When compiling the attached example:

With -O0, it eliminates a catch block since it can instantiate a template
resulting a non throwing method, but disregards the specialization in which an
exception is actually thrown. Adding the '-fnon-call-exceptions' flag this
doesn't happen, but that flag shouldn't be required. 

With -O2 and -O3 even the try block gets eliminated, but in that case the
'-fnon-call-exceptions' doesn't help.

Please see attachment:

$ g++-4.9 -O0 -Wall Client.cpp Test.cpp main.cpp && ./a.out
        Throwing exception
terminate called after throwing an instance of 'int'
Aborted

$ g++-4.9 -O0 -Wall -fnon-call-exceptions Client.cpp Test.cpp main.cpp &&
./a.out
        Throwing exception
        Exception handled!
        END

$ g++-4.9 -O2 -Wall Client.cpp Test.cpp main.cpp && ./a.out
        END

$ g++-4.9 -O3 -Wall Client.cpp Test.cpp main.cpp && ./a.out
        END

$ g++-4.9 -O2 -Wall -fnon-call-exceptions Client.cpp Test.cpp main.cpp &&
./a.out
        END

$ g++-4.9 -O3 -Wall -fnon-call-exceptions Client.cpp Test.cpp main.cpp &&
./a.out
        END

For comparison, clang++ works as expected with -O0, without the
-fnon-callexceptions. 
Although it has the same the behavior with higher optimization levels.


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

end of thread, other threads:[~2014-09-17 16:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-08 14:10 [Bug c++/62063] New: g++ disregards template specialization and skips try/catch blocks ferenc.geczi at ericsson dot com
2014-08-08 14:20 ` [Bug c++/62063] " redi at gcc dot gnu.org
2014-09-17 16:15 ` paolo.carlini at oracle dot com

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