-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Bump AVR c++ standard to 2014 from 2011 #7090
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
Conversation
Even though I would very much like to see C++14 support, I'm not sure how complete and correct the implementation in the avr-gcc version we use (which is not too recent) is. Do you have any info on that? |
You guys use gcc 4.9 right now. If https://gcc.gnu.org/projects/cxx-status.html#cxx14 is to be trusted, this gcc is missing variable templates, relaxed constexpr functions, member initializers, and sized deallocation, but has many other c++14 features. I took the time to review the behavior of this release of avr-g++ with regard to c++11 to c++14 breaking changes (mentioned in stm32duino/Arduino_Core_STM32#191). The behavior matched what the official website advertised:
The third item in this list is the only significant concern I see here. It is possible to write c++14 code using avr-gcc 4.9 which will then break on a future compiler release when relaxed constexpr functions are implemented (they will no longer be callable on const objects unless marked const). This is unfortunate; I'd like to see c++14 become the norm. So
I personally suspect these situations are rare enough to warrant implementing this change (does any arduino code use the constexpr keyword on a member function? this keyword didn't even exist before c++11). These two concerns could be dealt with at the same time if avr-g++ were additionally upgraded to at least version 5, when requirements on constexpr functions are relaxed. |
@xloem the next version of avr core is likely to be shipped with gcc 5.4 (Atmel toolchain 3.6.0 or 3.6.1). |
I checked with the new toolchain 3.6.0, gcc 5.4:
I think it would be great if the c++ compilation standard were bumped for this next toolchain! |
I made a switch to C++14 and gcc 5.4 on ARM-based Teensy about a year ago. It's worked quite well. I can't speak to all usage of constexpr, but I can say it works very well for constructors. |
I can confirm that the new toolchain works without any problems. Tested today with 1.6.205.. |
@harryboo, great! If we're going to bump to C++14, we should probably do the same for the SAM and SAMD cores. Anyone who wants to prepare a pullrequest for that (https://github.com/arduino/ArduinoCore-samd and https://github.com/arduino/ArduinoCore-sam) and/or test if bumping to C++14 there runs into any issues? |
The CMISIS we are shipping with SAMD produces a million warnings when compiled with gcc 7.2.0 . I believe that a full refresh of all companion tools could be needed before adopting a newer toolchain |
Ah, and I see we're currently on gcc 4.8 for SAM/SAMD, I thought those were already using newer versions. Ok, so that's a bit more work. Shouldn't block enabling C++14 for AVR, though? |
It would be better to enable it on all platforms at once 😉 It's not blocking, though |
any timeline for this? |
I'm closing this issue here; if we are still interested (probably C++17 would be a nicer target for the whole platform due the the increased |
Just look a this pseudocode: constexpr inline uint8_t digitalPinToPort(uint8_t pin) {
static constexpr uint8_t PROGMEM digital_pin_to_port[] = {/*...*/};
if (std::is_constant_evaluated())
return digital_pin_to_port_PGM[pin];
return pgm_read_byte(digital_pin_to_port + pin);
} For each Apart from faster execution, if there were no usage for this lookup tables while in runtime, those could be just skipped, in a result saving program memory for other things (sometimes those 30-200 bytes really save the ass). Anyway, its only one of possible usages inside Arduino core alone.. |
I don't think this is dependent on newer C++ versions, gcc already has |
No description provided.