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 8767461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:49:08+00:00 2026-06-13T16:49:08+00:00

Warning C4350 says A non-const reference may only be bound to an lvalue. I

  • 0

Warning C4350 says “A non-const reference may only be bound to an lvalue”. I think since C4350 is off by default I haven’t found much out there on it. I have read this post and it makes sense:
Non-const reference may only be bound to an lvalue

Anyway, I’m asking about it because I’m trying to update VS2008 VC++ projects to VS2012. When I do I get hundreds of C4350 warnings which I have turned on for some legacy reason (that admittedly may need to be reassessed). I have whittled it down to this simple bit of code that can reproduce the warning, but only if I have precompiled headers turned off:

#pragma warning(default:4350)

#include "stdafx.h"
#include <string>

int _tmain(int argc, char* argv[])
{
   return 0;
}

If I turn precomiled headers on I get no warning. I also can’t get it to happen in VS2008.

Is this a Visual Studio 2012 bug in std:string? Why does the precompiled header change the behavior? How do I fix the problem, as opposed to just ignoring the warning? Thanks!

The warning is (sorry for the poor formatting, it was the best I could figure):

c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstring(689): warning C4350: behavior change: ‘std::_Wrap_alloc<_Alloc>::_Wrap_alloc(const std::_Wrap_alloc<_Alloc> &) throw()’ called instead of ‘std::_Wrap_alloc<_Alloc>::_Wrap_alloc>(_Other &) throw()’

1> with

1> [

1> _Alloc=std::allocator

1> ]

1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xmemory0(838) : see declaration of ‘std::_Wrap_alloc<_Alloc>::_Wrap_alloc’

1> with

1> [

1> _Alloc=std::allocator

1> ]

1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xmemory0(850) : see declaration of ‘std::_Wrap_alloc<_Alloc>::_Wrap_alloc’

1> with

1> [

1> _Alloc=std::allocator

1> ]

1> A non-const reference may only be bound to an lvalue

1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstring(688) : while compiling class template member function ‘std::_Wrap_alloc<_Alloc> std::_String_alloc<_Al_has_storage,_Alloc_types>::_Getal(void) const’

1> with

1> [

1> _Alloc=std::allocator,

1> _Al_has_storage=false,

1> _Alloc_types=std::_String_base_types>

1> ]

1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstring(898) : see reference to function template instantiation ‘std::_Wrap_alloc<_Alloc> std::_String_alloc<_Al_has_storage,_Alloc_types>::_Getal(void) const’ being compiled

1> with

1> [

1> _Alloc=std::allocator,

1> _Al_has_storage=false,

1> _Alloc_types=std::_String_base_types>

1> ]

1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstring(700) : see reference to class template instantiation ‘std::_String_alloc<_Al_has_storage,_Alloc_types>’ being compiled

1> with

1> [

1> _Al_has_storage=false,

1> _Alloc_types=std::_String_base_types>

1> ]

1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\stdexcept(31) : see reference to class template instantiation ‘std::basic_string<_Elem,_Traits,_Alloc>’ being compiled

1> with

1> [

1> _Elem=char,

1> _Traits=std::char_traits,

1> _Alloc=std::allocator

1> ]

1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstring(689): warning C4350: behavior change: ‘std::_Wrap_alloc<_Alloc>::_Wrap_alloc(const std::_Wrap_alloc<_Alloc> &) throw()’ called instead of ‘std::_Wrap_alloc<_Alloc>::_Wrap_alloc>(_Other &) throw()’

1> with

1> [

1> _Alloc=std::allocator

1> ]

1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xmemory0(838) : see declaration of ‘std::_Wrap_alloc<_Alloc>::_Wrap_alloc’

1> with

1> [

1> _Alloc=std::allocator

1> ]

1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xmemory0(850) : see declaration of ‘std::_Wrap_alloc<_Alloc>::_Wrap_alloc’

1> with

1> [

1> _Alloc=std::allocator

1> ]

1> A non-const reference may only be bound to an lvalue

1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstring(688) : while compiling class template member function ‘std::_Wrap_alloc<_Alloc> std::_String_alloc<_Al_has_storage,_Alloc_types>::_Getal(void) const’

1> with

1> [

1> _Alloc=std::allocator,

1> _Al_has_storage=false,

1> _Alloc_types=std::_String_base_types>

1> ]

1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstring(898) : see reference to function template instantiation ‘std::_Wrap_alloc<_Alloc> std::_String_alloc<_Al_has_storage,_Alloc_types>::_Getal(void) const’ being compiled

1> with

1> [

1> _Alloc=std::allocator,

1> _Al_has_storage=false,

1> _Alloc_types=std::_String_base_types>

1> ]

1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstring(700) : see reference to class template instantiation ‘std::_String_alloc<_Al_has_storage,_Alloc_types>’ being compiled

1> with

1> [

1> _Al_has_storage=false,

1> _Alloc_types=std::_String_base_types>

1> ]

1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\string(689) : see reference to class template instantiation ‘std::basic_string<_Elem,_Traits,_Alloc>’ being compiled

1> with

1> [

1> _Elem=wchar_t,

1> _Traits=std::char_traits,

1> _Alloc=std::allocator

1> ]

  • 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-13T16:49:10+00:00Added an answer on June 13, 2026 at 4:49 pm

    Microsoft answered my question here:

    http://connect.microsoft.com/VisualStudio/feedback/details/767960/warning-c4350-behavior-change-when-including-string-and-no-precompiled-header

    Summary:

    Is this a Visual Studio 2012 bug in std:string?
    -They don’t count it as a bug if if cleanly builds at warning level 4, which excludes this warning

    Why does the precompiled header change the behavior?
    -The compiler ignores everything that comes before a precompiled header, which in this case was my pragma statement that was enabling the warning. Enabling precompiled headers in the property settings caused the pragma to be ignored. Who knew?

    How do I fix the problem, as opposed to just ignoring the warning?
    -No fix it would seem, just ignore the warning

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

Sidebar

Related Questions

Warning: I may have the wrong 'problem statement' but here it goes: A Campaign
warning: 'UITabBarController' may not respond to 'select Tab:' I am always getting a warning
warning: 'NSDate' may not respond to '+currDate' Above is a warning message when I
Warning: copy(/home/beradioc/public_html/phpfreechat-1.3/src/../data/public/themes/default/sound.swf) [function.copy]: failed to open stream: Permission denied in /home/beradioc/public_html/phpfreechat-1.3/src/pfctools.php on line 179
Warning: Non-static method Zend_Controller_Request_Http::getCookie() should not be called statically in.. Iam trying the following
WARNING: the background info is pretty long. Skip to the bottom if you think
Warning: move_uploaded_file(activities.png): failed to open stream: Permission denied in /var/www/vhosts/default/htdocs/backoffice/db/changelogo.php on line 17 Warning:
Warning: Note that this is a dumb question of something that I would probably
Warning: touch() [function.touch]: open_basedir restriction in effect. File() is not within the allowed path(s):
Warning: preg_replace_callback() [function.preg-replace-callback]: Requires argument 2, 'info', to be a valid callback in [...]

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.