0

STM32F7, GCC, FatFS

The following code corrupts the retVal. (For example, the vector is created with only one object, but when you inspect it has an absurd amount)

std::vector<uint8_t> SDManager::Test()
{
    std::vector<uint8_t> retVal(1);

    FIL file;

    retVal.push_back(0xFE);

    asm("nop");

    return retVal;
}

If you comment out "FIL file" then the vector is fine. But as soon as you put the FIL struct back in play, it corrupts the vector.

Next weird thing, if I were to create another vector, and then return use it as the function return object. The original vector becomes fine, however the newly returned vector becomes corrupted.

I'm very new to c++ so I need some guidance on how to diagnose this issue.

Thanks in advance.

Matt H
  • 137
  • 1
  • 10

1 Answers1

0

Have you implemented caddr_t sbrk(int incr) ? If not this may be the problem.

Stefan
  • 26
  • 1
  • 2