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

The problem with -fpermissive #11402

Closed
LostInCompilation opened this issue Apr 4, 2021 · 1 comment
Closed

The problem with -fpermissive #11402

LostInCompilation opened this issue Apr 4, 2021 · 1 comment
Labels
Component: Compilation Related to compilation of Arduino sketches Type: Bug Type: Duplicate Another item already exists for this topic

Comments

@LostInCompilation
Copy link

LostInCompilation commented Apr 4, 2021

Today a user from the German Arduino Facebook Group ran into a problem with switch/case producing invalid code. After some hours of searching, it turns out the culprit is the -fpermissive flag in Arduino.
This code should never ever compile, but it does thanks to the flag:

switch(...)
{
    case 0:
    int val = 42; // This should throw an error. You're not allowed to declare variables in a case label without using additional brackets! Results in crashing assembly
    // ...
    break;

  // ...
}

This is serious business, because the compiler produces an invalid assembly that skips instructions randomly, and the compiler doesn't even give an error.
I know why -fpermissive was introduced and also read the discussion here: #5021 (comment)
and here: arduino/ArduinoCore-avr#268

But accepting invalid and crashing code just because Arduino wants to support bad written libs and likes to suppress all warning is just non sense.

What are the plans for the flag?

@per1234
Copy link
Collaborator

per1234 commented Apr 5, 2021

Hi @MarcSchoendorf. Thanks for taking the time to submit an issue.

I see we already have a prior issue report about this at #10154.

It's best to have only a single issue per subject so we can consolidate all relevant discussion to one place, so I'll go ahead and close this in favor of the other.

If you end up with additional information to share, feel free to comment in the other thread.

@per1234 per1234 closed this as completed Apr 5, 2021
@per1234 per1234 added Component: Compilation Related to compilation of Arduino sketches Type: Bug Type: Duplicate Another item already exists for this topic labels Apr 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Compilation Related to compilation of Arduino sketches Type: Bug Type: Duplicate Another item already exists for this topic
Projects
None yet
Development

No branches or pull requests

2 participants