-
-
Notifications
You must be signed in to change notification settings - Fork 424
Open
Labels
topic: build-processRelated to the sketch build processRelated to the sketch build processtopic: codeRelated to content of the project itselfRelated to content of the project itselftype: imperfectionPerceived defect in any part of projectPerceived defect in any part of project
Description
Describe the problem
When trying to compile the following sketch,
template <size_t N>
void test(size_t arr[N / 2]) {}
void setup() {}
void loop() {}
this error is raised:
arduino-cli compile --fqbn arduino:avr:pro --warnings all --output-dir build \
--build-property compiler.cpp.extra_flags="-pedantic"
.../x.ino.cpp:2:7: warning: line number out of range
#line 0 ".../x.ino"
^
.../x.ino:0:43: error: stray '\' in program
.../x.ino:6:7: warning: line number out of range
When the function definition is changed as follows, everything works fine.
void test(size_t arr[N >> 1]) {}
This issue seems to be independent of which core is used (tried AVR and ESP) and of which platform is used (tried Linux and Wokwi simulator).
Arduino CLI version
Operating system
- Windows
Operating system version
- Windows 11
Additional context
For reference, the following program compiles without errors or warnings
#include <cstddef>
template <size_t N>
void test(size_t arr[N / 2]) {}
int main() {
return 0;
}
with the following command:
g++ -std=c++11 -Wall -Wextra -pedantic x.cc
Issue checklist
- I searched for previous reports inI verified the problem still occurs when using theMy report contains all necessary detailsTo pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Metadata
Metadata
Assignees
Labels
topic: build-processRelated to the sketch build processRelated to the sketch build processtopic: codeRelated to content of the project itselfRelated to content of the project itselftype: imperfectionPerceived defect in any part of projectPerceived defect in any part of project
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
per1234 commentedon Jun 27, 2022
Thanks for your report @jfjlaros.
You can see the problem in the program produced after Arduino sketch preprocessing:
Note the backslash that was inserted into the generated prototype:
facchinm commentedon Jun 27, 2022
@per1234 done 😉
@jfjlaros it's indeed a nasty bug, mostly due to the fact that
ctags
is not very template friendly, so we had to create special cases and probably multiline is not well tested. Thanks for the PoC btwjfjlaros commentedon Jul 5, 2022
Here is an other one. The following function definition
gives rise to these errors (different than the ones in the previous example)
while
compiles fine.
[-]Preprocessing bug (probably).[/-][+]Preprocessing bug[/+][-]Preprocessing bug[/-][+]Backslash incorrectly inserted into generated prototype for multiline template function [/+].ino
file #2946