Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8345051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:33:52+00:00 2026-06-09T06:33:52+00:00

The problem. See the below code… I was missing the return field; statement and

  • 0

The problem.
See the below code… I was missing the return field; statement and didn’t spot it for a few debug runs. I would never have thought that something like that would get past the compiler without an error! Why did it?

Description
I have an parser object that uses std::tr1::function to have receive a translation algorithm on construction. The translation converts from a string to an object of type TransportableMessage, which is made of TMFields, which can hold different types. So anyway I made a factory function for the creation of the fields because the type of the field is based on a string (from the XML), and while there is only a few now, it may be that there are more in the future.

The tstring object is a typecast based on UNICODE and basically resolves to std::wstring at the minute. Also because I am using VS2008 unique_ptr is not there so I have hidden std::auto_ptr behind ScopedPtr_t to make an upgrade easier and thus more likely to happen.

namespace arc
{
    namespace util
    {

        int internalTest()
        {
            std::cout << "Any error?" << std::endl;
        }

        ScopedPtr_T<TMField> TmFieldFactory( const tstring& name, const tstring& typeName, const tstring& value )
        {
            ScopedPtr_T<TMField> field;
            int a = internalTest();
            if( typeName == _T("int") || typeName == _T("long") )
            {
                field.reset( new TMNumericField( name, boost::lexical_cast<__int64>(value) ) );
            }
            else if( typeName == _T("string") )
            {
                field.reset( new TMStringField( name, value ) );
            }
            else if( typeName == _T("timestamp") )
            {
                field.reset( new TMTimeField( name, boost::lexical_cast<__int64>(value) ) );
            }
            else
            {
                std::string info( __FILE__ " :: " __FUNCTION__ " : Unrecognized TmField type ");
                std::string type( typeName.begin(), typeName.end() );
                info += type;
                throw ARC_Exception( info.c_str() );
            }
            return field; // I WAS MISSING THIS!
        }
    }
}

Basically I would like to know if anyone else has had problems with this? I introduced the function internalTest to see if the problem was specific to scoped_ptrs but it appears that it is not. I also tried using internalTest in GCC and it returned an error.
Why did it Visual Studio not flag this? Am I missing a compilation setting somewhere that I can turn on? Does the standard allow this? Apologies if this is something well known, I did google and look for answers here.

EDIT:: Calling Code – Just adding this for more context.

SharedPtr_T<TransportableMessage> strToTmConvFunc_Default_Apc7_0(const std::string& tm_str)
{
    pugi::xml_document xmlDoc;
    if( false == xmlDoc.load( tm_str.c_str() ) )
    {
        ARC_LOG(LOG_WARN, "The passed TM object was malformed. %s", tm_str.c_str() );
        throw ARC_Exception( "Malformed Transportable Message XML" );
    }

    pugi::xml_node tmBase = xmlDoc.first_child();
    std::string xmlRootName( tmBase.name() );
    if( xmlRootName.compare("TM") != 0 )
    {
        ARC_LOG(LOG_WARN, "The passed TM object was malformed. %s", tm_str.c_str() );
        throw ARC_Exception( "Malformed Transportable Message XML" );
    }

    std::string tmname = tmBase.child("N").child_value();
    std::string entity = tmBase.child("E").child_value();
    ARC_LOG(LOG_INFO, "TM message received for parsing. TM name is %s", tmname.c_str() );

    tstring t_tmname( tmname.begin(), tmname.end() );
    SharedPtr_T<TransportableMessage> tm_obj( new TransportableMessage( t_tmname, 0 ) );

    pugi::xml_node fields = tmBase.child("FS");
    for( pugi::xml_node field = fields.first_child(); field; field = field.next_sibling("field") )
    {
        tm_obj->addField( arc::util::TmFieldFactory( field.child_value("N"), field.child_value("T"), field.child_value("V") ) );
    }

    return tm_obj;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:33:54+00:00Added an answer on June 9, 2026 at 6:33 am

    Falling off the body of a function without returning something is not an error, it is undefined behavior; see 6.3.3 The return statement [stmt.return] §3:

    Flowing off the end of a function is equivalent to a return with no value; this results in undefined behavior in a value-returning function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've a problem with CakePHP __() function. Please see the code below : $options
I am having a problem using the signedCMS.decode routine. See the code below. The
Please see my pseudo-code below. The code comments should explain my problem. I'm new
I have a problem with some jquery please see below code. I have 2
I have problem with session and query execution,please see code below. class A implements
I have problem with session and query execution, please see code below. class A
Problem solved, see below Question I'm working in Flex Builder 3 and I have
EDIT: This problem has been solved. See below. Hey all. I'm building an iPhone
hey everyone, here is the site SEE BELOW I have a slight jquery problem
(Problem solved now, see answers below) Hello, in my app I am trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.