Warning from compiler regarding new.cpp

I have just compiled some code, and four equal warning were issued from compiler. This is how one warning looks, and it seems to be something about a tag in a function, that I do not know about:

C:\Users\viggo\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino\new.cpp: In function 'void* operator new(std::size_t, std::nothrow_t)':
C:\Users\viggo\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino\new.cpp:59:60: warning: unused parameter 'tag' [-Wunused-parameter]
 void * operator new(std::size_t size, const std::nothrow_t tag) noexcept {
                                                            ^~~

The last pointer points to the tag in the parameter for the function, new(). I noticed, that the file new.cpp do not seem to have changed since december.

I have not made any changes to my code past week, and therefore I am surprised to see these warnings now. My sketch do seem to work OK. I like to resolve any warnings, and I hope for help to remove these.

Maybe when compiling this previously you were doing so with compiler warnings turned off. Note that it's a warning, not an error, so it won't necessarily create problems.

Note also that for some Arduino platforms, compiler warnings are turned on by default, but for others it's turned off. So you can also see changes in behavior across different boards/platforms.

This is caused by a parameter for the function not being used within the function. Not sure why the parameter is there, may be for compatibility with older versions that did use the parameter, or preparation for something that will be added in the future.

I have been seeing a set of four warnings like this for months. The warnings are only displayed the first time you compile the core after opening the IDE or changing the board selection, because the compiler caches the compiled code and only re-compiles if the source code has been altered.

1 Like

I did not change these preferences, and I think I have had these warnings turned on past 4 month.

I can confirm this to be the case. When I tried to compile again, I did not get these warnings again.

Hi @backflip. The developers of the "Arduino AVR Boards" platform are tracking the need to fix this warning here:

As was already explained, you can safely ignore the warning. If you are using Arduino IDE 2.x, you should see the warning infrequently since (as @david_2018 explained), the compiled core is cached and you will only only see the warnings on that first compilation for a given board when the core cache is not present.

Arduino IDE 1.x does clear the cache each time you exit the IDE so you will see the warning more frequently if you are using an outdated version of the IDE. You will also see it if an external clean-up process deletes your system temporary folder (but Windows doesn't do that automatically so Windows users should find that the cache is persistent unless they are using some application that cleans the temporary folder, or are deleting it manually).

If you are (understandably) bothered by the warning, you can open the new.cpp file in a text editor and change the code to fix the warning. The community has submitted various proposals for how to do that, so you can pick whichever of their approaches you think is best (I use the cast to void approach in my own code):

Thank you for your answer. Perhaps some update have taken place, that make it appear this once. But when I repeat now, I do not get an error, so it is not bothering me for now, and therefore I will let it be for the time being. The IDE provides me with this information about the version:
Arduino IDE version

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.