Skip to content
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

New (valid) warnings raised by GCC 11 in v1.58 beta 2 #660

Open
tttapa opened this issue Oct 3, 2022 · 0 comments
Open

New (valid) warnings raised by GCC 11 in v1.58 beta 2 #660

tttapa opened this issue Oct 3, 2022 · 0 comments

Comments

@tttapa
Copy link

tttapa commented Oct 3, 2022

Hi Paul,

When compiling using GCC 11 from Teensyduino 1.58 beta 2 with -Wextra enabled, I get the following two warnings in the Teensy core files. (I usually compile with -Wall -Wextra -Werror in the CI builds for my libraries.)
I believe that these warnings are indeed valid.

In file included from /home/pieter/.arduino15/packages/teensy/hardware/avr/1.58.0-beta2/libraries/SPI/SPI.h:23:
/home/pieter/.arduino15/packages/teensy/hardware/avr/1.58.0-beta2/cores/teensy3/DMAChannel.h: In copy constructor 'DMASetting::DMASetting(const DMASetting&)':
/home/pieter/.arduino15/packages/teensy/hardware/avr/1.58.0-beta2/cores/teensy3/DMAChannel.h:405:25: error: implicitly-declared 'constexpr DMASetting& DMASetting::operator=(const DMASetting&)' is deprecated [-Werror=deprecated-copy]
  405 |                 *this = c;
      |                         ^
/home/pieter/.arduino15/packages/teensy/hardware/avr/1.58.0-beta2/cores/teensy3/DMAChannel.h:403:9: note: because 'DMASetting' has user-provided 'DMASetting::DMASetting(const DMASetting&)'
  403 |         DMASetting(const DMASetting &c) {
      |         ^~~~~~~~~~

Here, the implicitly declared copy assignment operator operator=(const DMASetting &) is used instead of the user-defined assignment operator operator=(const DMABaseClass &). Although I'm not familiar with the specifics, I believe this might be a mistake, because copy_tcd is not called in this case.
If it is indeed a mistake, I'd recommend explicitly implementing or =deleteing operator=(const DMASetting &). If it's not a mistake, I think you should be able to explicitly use DMASetting &operator=(const DMASetting &) = default.

With USB type set to MIDI, you also get this warning about an invalid function pointer cast:

In file included from /home/pieter/.arduino15/packages/teensy/hardware/avr/1.58.0-beta2/cores/teensy3/WProgram.h:62,
                 from /tmp/arduino_build_737688/pch/Arduino.h:6:
/home/pieter/.arduino15/packages/teensy/hardware/avr/1.58.0-beta2/cores/teensy3/usb_midi.h: In member function 'void usb_midi_class::setHandleSysEx(void (*)(const uint8_t*, uint16_t, bool))':
/home/pieter/.arduino15/packages/teensy/hardware/avr/1.58.0-beta2/cores/teensy3/usb_midi.h:327:47: warning: cast between incompatible function types from 'void (*)(const uint8_t*, uint16_t, bool)' {aka 'void (*)(const unsigned char*, short unsigned int, bool)'} to 'void (*)(const uint8_t*, uint16_t, uint8_t)' {aka 'void (*)(const unsigned char*, short unsigned int, unsigned char)'} [-Wcast-function-type]
  327 |                 usb_midi_handleSysExPartial = (void (*)(const uint8_t *, uint16_t, uint8_t))fptr;
      |                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/pieter/.arduino15/packages/teensy/hardware/avr/1.58.0-beta2/cores/teensy3/usb_midi.h: In member function 'void usb_midi_class::setHandleSystemExclusive(void (*)(const uint8_t*, uint16_t, bool))':
/home/pieter/.arduino15/packages/teensy/hardware/avr/1.58.0-beta2/cores/teensy3/usb_midi.h:331:47: warning: cast between incompatible function types from 'void (*)(const uint8_t*, uint16_t, bool)' {aka 'void (*)(const unsigned char*, short unsigned int, bool)'} to 'void (*)(const uint8_t*, uint16_t, uint8_t)' {aka 'void (*)(const unsigned char*, short unsigned int, unsigned char)'} [-Wcast-function-type]
  331 |                 usb_midi_handleSysExPartial = (void (*)(const uint8_t *, uint16_t, uint8_t))fptr;
      |                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Although this is probably fine, it still invokes undefined behavior, and it would be nice to get rid of the warning (and the cast) anyway by using the same signature everywhere.

To reproduce: create an empty sketch and add a .cpp file to it with the following contents (I ignored unused parameter warnings to filter out some of the noise):

#pragma GCC diagnostic warning "-Wextra"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <Arduino.h>
#include <SPI.h>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant