CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21
  1. #16
    Join Date
    Dec 2013
    Posts
    14

    Re: Debug Assertion Failed! due to the use of ifstream

    Quote Originally Posted by 2kaud View Post
    In calcPayFixes, there are several lines of code like this
    Code:
    if (cnt <= payDates_.size())
    Are you sure this test should be <= and not < as the elements of the vector go from 0 to .size() -1?
    To be honnest, I cannot say since the whole code does not come from me. But I still working on this matter.
    Last edited by eBooster; March 12th, 2014 at 09:17 AM.

  2. #17
    Join Date
    Dec 2013
    Posts
    14

    Re: Debug Assertion Failed! due to the use of ifstream

    Quote Originally Posted by 2kaud View Post
    Possibly because of what I mentioned in my previous post #13.
    I tried your advice in post #13 without success.

  3. #18
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: Debug Assertion Failed! due to the use of ifstream

    Quote Originally Posted by eBooster View Post
    To be honnest, I cannot say since the whole code does not come from me. But I still working on this matter.
    Are you sure that the parameters you are passing to the constructor of s are correct and valid?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  4. #19
    Join Date
    Dec 2013
    Posts
    14

    Re: Debug Assertion Failed! due to the use of ifstream

    Quote Originally Posted by 2kaud View Post
    Are you sure that the parameters you are passing to the constructor of s are correct and valid?
    Yes, I have checked this, but I think it come from the source you said in post #13.
    Last edited by eBooster; March 12th, 2014 at 12:03 PM.

  5. #20
    Join Date
    Dec 2013
    Posts
    14

    Re: Debug Assertion Failed! due to the use of ifstream

    Quote Originally Posted by 2kaud View Post
    In calcPayFixes, there are several lines of code like this
    Code:
    if (cnt <= payDates_.size())
    Are you sure this test should be <= and not < as the elements of the vector go from 0 to .size() -1?
    You were since very close : the bug came from the second line after the one you highlighted.

    if (cnt <= payDates_.size())
    {
    if (cnt + payFrequency_ < payDates_.size()) //< instead of <=

  6. #21
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: Debug Assertion Failed! due to the use of ifstream

    I'm pleased you found the issue. I'm always very wary when I see <= relating to elements of a container.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

Page 2 of 2 FirstFirst 12

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