The project is almost over. We took it last FridaySource codeDeploy at the customer's company.
Same copyCodeWith the old version of the GCC compiler, there is a bad precognition during compilation, and the compiledProgramThe execution result is incorrect.
After debugging in Linux for half a day, I finally reduced the problem to the following code line:
FS. Open (filepath, IOS: Binary | IOs: APP );
This FS is passed by the template parameters of the function, that is, it may be an input stream or an output stream, the main function of this part of the code is to verify whether the file to be opened is legal and to open the incoming file stream.
When the imported FS is an input stream, the open function of FS fails to be executed, that is, the specified file cannot be opened.
For the input stream, it only reads the content in the stream and does not need to append it. So I tried to remove the IOS: app tag, and the input stream can be opened normally.
Let's think about whether a function carries chaotic responsibilities. Only when the input stream opens this strange code in APP mode, we finally decide to extract a function separately by checking whether the file is legal, the caller maintains the opening of the file stream.
Conclusion: The GCC compiler of the old version imposes strict restrictions on the open mark of the input stream ifstream. Opening an input stream in APP mode will fail.
The GCC compiler of the latest version is more humane. Opening an input stream in APP mode does not cause a stream opening failure, but this app mode does not work for the input stream.