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++/54046] New: wrong control reaches end of non-void function for switch case with throw and default


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

             Bug #: 54046
           Summary: wrong control reaches end of non-void function for
                    switch case with throw and default
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: plasmahh@gmx.net


Hi, somehow gcc gets confused in its control flow analysis when a default case
in a switch has a throw and break, and a variable with user defined dtor.

struct A
{
        ~A() { }
};

bool check( int x )
{
        A z;
        switch( x )
        {
                case 0:
                        return false;
                default:
                        throw "X";
                        break;
        }
}

When I either remove the break or the variable z, the warning will not issued
anymore.


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