Skip to content

Cannot compile sketch containing invisible characters #1808

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

Closed
3 tasks done
kittaakos opened this issue Jul 19, 2022 · 1 comment
Closed
3 tasks done

Cannot compile sketch containing invisible characters #1808

kittaakos opened this issue Jul 19, 2022 · 1 comment
Labels
conclusion: invalid Issue/PR not valid topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@kittaakos
Copy link
Contributor

Describe the problem

Sketch compilation fails if the sketch contains invisible characters. I do not know if it's a builder, preprocessor, or pure C++ issue.

To reproduce

void setup() {
  char s = 'x' ;
}
void loop() {}

Note that after the 'x' there is an invisible character.
Screen Shot 2022-07-19 at 11 37 51
Screen Shot 2022-07-19 at 11 37 30

Compilation:

a.kitta@Akoss-MacBook-Pro sketch_jul18b % ~/dev/git/arduino-ide/arduino-ide-extension/build/arduino-cli version
arduino-cli  Version: 0.25.0-rc1 Commit: 63b53c0f Date: 2022-07-11T16:09:52Z
a.kitta@Akoss-MacBook-Pro sketch_jul18b % cat ~/Documents/Arduino/sketch_jul18b/sketch_jul18b.ino 
void setup() {
  char s = 'x' ;
}
void loop() {}
a.kitta@Akoss-MacBook-Pro sketch_jul18b % ~/dev/git/arduino-ide/arduino-ide-extension/build/arduino-cli compile -b arduino:samd:mkr1000 ~/Documents/Arduino/sketch_jul18b 
/Users/a.kitta/Documents/Arduino/sketch_jul18b/sketch_jul18b.ino:2:15: error: stray '\302' in program
   char s = 'x'��;
               ^
/Users/a.kitta/Documents/Arduino/sketch_jul18b/sketch_jul18b.ino:2:16: error: stray '\240' in program
   char s = 'x'��;
                ^



Used platform Version Path                                                                  
arduino:samd  1.8.13  /Users/a.kitta/Library/Arduino15/packages/arduino/hardware/samd/1.8.13

Error during build: exit status 1

Expected behavior

If it's possible to compile a cpp file that contains the <0xa0> invisible character, I would expect to work with the CLI too.

Arduino CLI version

arduino-cli Version: 0.25.0-rc1 Commit: 63b53c0 Date: 2022-07-11T16:09:52Z

Operating system

macOS

Operating system version

12.3.1

Additional context

Based initially on arduino/arduino-ide#1210.
Possibly related (based on the compiler error message): #1785

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the nightly build
  • My report contains all necessary details
@kittaakos kittaakos added the type: imperfection Perceived defect in any part of project label Jul 19, 2022
@matthijskooijman
Copy link
Collaborator

Looks like an error thrown by gcc. I am pretty (but not 100%) sure that including such characters (at least outside of a string constant) produces an invalid C++ file, so gcc is correct to complain. I'm going to go ahead and closes this for not being an actual bug.

One could argue that there is a bug where these invisible characters should be more prominently displayed somehow, but that would need to reported in another repository (and I think this is unlikely to be fixed in 1.x, and I suspect your last screenshot is from 2.x, so it would already be reasonably handled there?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: invalid Issue/PR not valid topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

3 participants