Skip to content

Should not compile with -fpermissive? #268

Open
@matthijskooijman

Description

@matthijskooijman

Today, I ran into some problem, which turned out to be caused by the compiler happily passing an int to a function that expected a pointer. Closer investigation showed that a warning was issued, where I would have expected an error. This seems to because of the -fpermissive flag, which gets passed by the avr core by default. According to the gcc manpage:

   -fpermissive
       Downgrade some diagnostics about nonconformant code from
       errors to warnings.  Thus, using -fpermissive allows some
       nonconforming code to compile.

I'm not sure what changes this makes exactly and if we need it at all. If the other changes are similar to this one, I think it should be disabled at some point (but it will probably break existing code that isn't quite correct, but now happens to work)...

For reference, here's a simplified version of my problem:

void func(Foo *ptr);

int main() {
  func(1);
  return 0;
}

(the real problem was more subtle, involving a struct with a conversion operator to int, which got silently converted to a pointer containing rubbish when I forgot the & operator when trying to pass the struct's address to a function).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions