flang icon indicating copy to clipboard operation
flang copied to clipboard

Make backslash behaviour compatible with gfortran

Open bryanpkc opened this issue 4 years ago • 1 comments

There are several issues with the -Mbackslash option.

  1. Currently, Flang's default behaviour is not compatible with that of gfortran and ifort (as explained in Arm's own documentation). Some of our users have found it cumbersome to have to add -Mbackslash or -fno-backslash when compiling programs that were originally compiled with gfortran. Can we consider changing Flang's default behaviour to be consistent with gfortran and ifort?

  2. The documentation for -Mbackslash and -Mnobackslash is incorrect. Both README.md and Using Flang state the following, which is the opposite of reality (not to mention the unnecessary hyphen):

    -Mbackslash           Treat backslash character like a C-style escape character
    -Mno-backslash        Treat backslash like any other character
    

    Contrast this with NVIDIA's documentation for nvfortran:

    -Mbackslash instructs the compiler to treat the backslash as a normal character, and not as an escape character in quoted strings. -Mnobackslash instructs the compiler to recognize a backslash as an escape character in quoted strings (in accordance with standard C usage).

    I will submit a PR to update the wording in the documentation.

  3. It is both counter-intuitive and confusing for -Mbackslash to mean the same thing as -fno-backslash, and for -Mnobackslash to mean the same thing as -fbackslash. I understand that there may be users that rely on the legacy semantics of these options, so there may not be a lot we can do here.

bryanpkc avatar Apr 10 '21 03:04 bryanpkc

I propose to stop Flang from enabling the backslash extension by default, to better align with gfortran and ifort, and also to deprecate the -M options in favour of the -f ones.

@mleair @pawosm-arm @shivaramaarao @SouraVX What do you guys think?

bryanpkc avatar Apr 25 '21 16:04 bryanpkc