CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Jul 2001
    Posts
    8

    Question VC++ 10 impact on existing code?

    Are any of the new features in C++ that are going to be in VC++ 10 going to negatively impact existing programs?

  2. #2
    Join Date
    Dec 2008
    Posts
    21

    Re: VC++ 10 impact on existing code?

    Hello

    So I guess it depends on what you mean by “negatively impact”. If you look at the repurposing of “auto” then clearly yes, valid existing code may now break:

    auto int i = 0; // now illegal in C++0x

    So far we have not seen any real issues with this anyhow. The CTP has a switch to maintain the old semantics too.

    The Lambda syntax looks like the MS attributes syntax and Jonathan had to do a lot of work to check that we parsed them correctly, but users should not see an issue.

    Our other additions do not use existing syntax, so I think we are mostly fine – but this is the whole point of having a CTP, so you can try it out with your codebase and verify this. Also we would expect to have bug or two, the earlier we find them the better too.

    Of course, adding new functionality may make the compiler itself either a little bigger or possibly a little slower (if it has more options to check with new functionality/keywords) but we have seen nothing significant here – again let us know your experience with the CTP

    Thanks
    Damien

  3. #3
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: VC++ 10 impact on existing code?

    Asside from the "required" breaking changes (e.g. auto keyword repurposing) are there ANY features from VS-2008 (especially invluding SP1) that are not in the CTP?

    If there are any (probably due to overlap in the releases) will they all be resolved by Relase?
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  4. #4
    Join Date
    May 2006
    Posts
    22

    Re: VC++ 10 impact on existing code?

    There is one change that fell out of the implementaion of rvalue references that has broken some code bases internally. It is code like the following:

    Code:
    struct S
    {
    	S();
    	explicit S(const S&);
    };
    
    void f(S);
    
    int main()
    {
    	S s;
    
    	f(s);
    }
    This code compiles with Visual C++ 2008 SP1 (and with previous compilers) but it is, correctly, rejected by Dev10. If you make the default copy-constructor of a class 'explicit' you are saying that you can't pass an instance of the class to a function. The "fix" in every case we have seen so far is to remove the 'explicit' keyword from the default copy-constructor - it was usually added as a result of over enthusiasm.
    Jonathan Caves
    Visual C++ Compiler Team

  5. #5
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: VC++ 10 impact on existing code?

    That is actually GREAT news. Putting the explicit on a copy consstuctor SHOULD prevent passing arguments by value. It has long annoied me that this was not detected.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  6. #6
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: VC++ 10 impact on existing code?

    Quote Originally Posted by joncaves
    This code compiles with Visual C++ 2008 SP1 (and with previous compilers) but it is, correctly, rejected by Dev10. If you make the default copy-constructor of a class 'explicit' you are saying that you can't pass an instance of the class to a function. The "fix" in every case we have seen so far is to remove the 'explicit' keyword from the default copy-constructor - it was usually added as a result of over enthusiasm.
    Ah, but this is just a bug fix rather than due to a C++0x clarification of semantics, right?
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  7. #7
    Join Date
    Nov 2008
    Location
    England
    Posts
    748

    Re: VC++ 10 impact on existing code?

    Quote Originally Posted by joncaves View Post
    There is one change that fell out of the implementaion of rvalue references that has broken some code bases internally. It is code like the following:

    Code:
    struct S
    {
        S();
        explicit S(const S&);
    };
     
    void f(S);
     
    int main()
    {
        S s;
     
        f(s);
    }
    This code compiles with Visual C++ 2008 SP1 (and with previous compilers) but it is, correctly, rejected by Dev10. If you make the default copy-constructor of a class 'explicit' you are saying that you can't pass an instance of the class to a function. The "fix" in every case we have seen so far is to remove the 'explicit' keyword from the default copy-constructor - it was usually added as a result of over enthusiasm.
    Learnt something new. I never understood why people make copy constructors explicit because as far as I knew it only prevented assignment-looking calls to the copy constructor.

    ie.

    classname a;
    classname b(a); // is ok if copy constructor is explicit
    classname c = a; // fails if classname has explicit copy constructor.

    I suppose thinking about it passing by value would be an implicit call and not an explicit call.

    Is there ever a good reason to make copy constructors explicit?
    Personally i have only used explicit constructors for single argument or multiargument constructors where all but one argument has a default value.

    While talking about explicit, is it so hard to implement explicit conversion operators which is something I felt c++ needed for years?
    Get Microsoft Visual C++ Express here or CodeBlocks here.
    Get STLFilt here to radically improve error messages when using the STL.
    Get these two can't live without C++ libraries, BOOST here and Loki here.
    Check your code with the Comeau Compiler and FlexeLint for standards compliance and some subtle errors.
    Always use [code] code tags [/code] to make code legible and preserve indentation.
    Do not ask for help writing destructive software such as viruses, gamehacks, keyloggers and the suchlike.

  8. #8
    Join Date
    Dec 2008
    Posts
    1

    Re: VC++ 10 impact on existing code?

    Our library changes (not present in the CTP) will break some nonconformant programs. One popular example, occurring throughout VS's own codebase, is people using back_inserter() without including <iterator>. We changed our header dependencies (the Standard headers include each other in unspecified ways), and now <iterator> isn't dragged into some translation units where it was before.

    Obviously, we're trying with all our might to avoid breaking conformant programs. But we depend on CTP and Beta feedback to identify as many occurrences of this as possible - as large as our test matrix and internal codebase are, they're dwarfed by our users' codebases.

  9. #9
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: VC++ 10 impact on existing code?

    Actually that is a welcome (sort-of) breaking change. Anything that reduces dependancies is good

    A few years ago I wrote a fairly decent analizer for C++ #include hierarchies, making sure that the structure was minimal (don;t include things that are NOT needed), yet complete (including a single header will always compile). Saved lots of time over the lifecycle of the program.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  10. #10
    Join Date
    Dec 2008
    Posts
    21

    Re: VC++ 10 impact on existing code?

    Hello

    Probably a little off-topic for this posting, but on re-reading I thought I should also mention the move to MS Build as the build system in VC2010 (this is a change but is not a language/libraries change and most importantly this should not be a breaking change.) Marian has a great post on this if you want more information: http://blogs.msdn.com/vcblog/archive...msbuild-n.aspx.

    Thanks
    Damien

  11. #11
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: VC++ 10 impact on existing code?

    Hmm. I notice that mentions building multiple projects in parallel. Hopefully someone's fixed the (annoying but not actually damaging) issue where one build complains that it can't open the build log file because another build is using it.

  12. #12
    Join Date
    Jul 2008
    Posts
    3

    Re: VC++ 10 impact on existing code?

    Hi,

    This should be fixed as part of the new project system. Earlier developers could run into this if two projects resided in the same folder and were writing to the same log file accidently ($(IntDir)\BuildLog.htm).

    In the new project system the build log file names will be patterned to be unique based on the name of the project thus correcting this behavior.

    Thanks,

    Amit Mohindra
    Visual C++ Team

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured