Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Disable "unreachable code" warning in xml parsing. #163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

unvestigate
Copy link
Contributor

The for loop on line 325 in xml_parsing.cpp emits a-warning-as-error "unreachable code detected", when building on MSVC in release mode. Because the body of the loop always throws an error the increment-part of the for loop is never executed. Maybe you want to change this to not use a loop in the future, but this way we can build at least. Tested on MSVC 2015.

@facontidavide
Copy link
Collaborator

Can you please be more specific about the warning you are trying to fix?

@unvestigate
Copy link
Contributor Author

It is warning C4702. If I try to build xml_parsing.cpp in release mode on MSVC I get this:

1>d:\projects\behaviortree.cpp\src\xml_parsing.cpp(326): error C2220: warning treated as error - no 'object' file generated
1>d:\projects\behaviortree.cpp\src\xml_parsing.cpp(326): warning C4702: unreachable code

@unvestigate
Copy link
Contributor Author

This for-loop always throws an error (both the if- and else-block). Because of this the "child = child->NextSiblingElement()" part is never executed, which MSVC does not like.

for (auto child = node->FirstChildElement(); child != nullptr;
                 child = child->NextSiblingElement())
            {
                if( StrEqual(child->Name(), "remap") )
                {
                   ThrowError(node->GetLineNum(), "<remap> was deprecated");
                }
                else
		{
                    ThrowError(node->GetLineNum(), "<SubTree> should not have any child");
                }
            }

facontidavide added a commit that referenced this pull request Mar 19, 2020
@facontidavide
Copy link
Collaborator

just pushed a different solution. Thanks for contributing :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants