-
Notifications
You must be signed in to change notification settings - Fork 106
mismatched delete #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi Francesco (@FStefanni ), Thanks for this. I suspect we haven't seen this issue before because on Arduino platforms the implementations of
Best wishes, |
Hi, yes, very often also Regards. |
Hi Francesco (@FStefanni ), I've looked into this and I believe I am using the new operator correctly, certainly as far as the compilers used by Arduino are concerned. Please see this link https://www.cplusplus.com/reference/new/operator%20new[]/ , specifically lines 13 and 18 of the example. In many places, I do create a new array directly: SparkFun_u-blox_GNSS_Arduino_Library/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp Line 377 in 46c1855
Both of these alternatives generate compilation errors:
Likewise, where I use typedef struct to define how much memory should be allocated: SparkFun_u-blox_GNSS_Arduino_Library/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp Line 4511 in 46c1855
Replacing this with:
also generates a compilation error. I'm going to close this as I don't believe there is any further action I can take. Please reopen if you can provide code which compiles successfully on Arduino platforms. Best wishes, |
Hi, sorry, maybe I was not clear. Example 1:
Example 2:
Example 3:
Other combinations are not allowed. For example it is not possible to do something as:
If the memory function are mixed, the code will compile, without any warning, but it will be non standard.
So the fix is just to match something as:
with
Regards. PS: it seems I cannot re-open the issue... |
Hi Francesco (@FStefanni ), Thank you for the clarification! Best wishes, |
Hi, now it seems fine to me. Regards. |
Subject of the issue
Hi,
in the code, there are mismatched deletes.
In C++
new
must match adelete
andnew[]
must matchdelete[]
.In the code, there are only
delete[]
, even fornew
.For example, in file
SparkFun_u-blox_GNSS_Arduino_Library.cpp
:and basically, all struct-based data pointers have this issue.
This mismatch could lead the code to crash, since it goes into undefined behavior.
Regards.
The text was updated successfully, but these errors were encountered: