[flang-commits] [PATCH] D153916: [flang][NFC] Add F2023X documentation

Brad Richardson via Phabricator via flang-commits flang-commits at lists.llvm.org
Tue Jun 27 17:32:50 PDT 2023


everythingfunctional added inline comments.


================
Comment at: flang/docs/F202X.md:90-95
+```
+  character(:), allocatable :: buffer
+  allocate(character(20)::buffer)
+  write(buffer,'F5.3') 3.14159
+  print *, len(buffer)
+```
----------------
klausler wrote:
> everythingfunctional wrote:
> > I'd be curious to know if you have any examples of real world code that rely on the length of a buffer not changing, or would have meaningful different observable behaviour. In my experience the typical usage would be more like:
> > 
> > ```
> >   character(:), allocatable :: buffer
> >   allocate(character(20)::buffer)
> >   write(buffer,'F5.3') 3.14159
> >   print *, trim(buffer)
> > ```
> > 
> > which wouldn't show observably different behavior. Or at worst:
> > 
> > ```
> >   character(:), allocatable :: buffer
> >   allocate(character(20)::buffer)
> >   write(buffer,'F5.3') 3.14159
> >   print *, buffer
> > ```
> > 
> > where it is observably different (no more trailing blanks), but is likely to be a welcome change, not an unwelcome one.
> I'm going to have to add portability warnings for usage of deferred-length character allocatables in these contexts and see how often they are triggered by nonclassified codes in order to give you an accurate reproducible answer to that.  Part of the difficulty here is that this isn't usage that can be easily grepped for.
I think you're going to get a lot of false positives that way. I suspect the majority of cases will be from code that looks like:

```
character(:), allocatable :: buffer
allocate(character(1000) :: buffer)
write(buffer, 'F5.3') 3.14159
buffer = trim(buffer)
```

and are going to go, oh good, I can delete those two lines and just write:

```
character(:), allocatable :: buffer
write(buffer, 'F5.3') 3.14159
```

Now how do I turn the warning off? I'll tell you right now I'm in that camp.

My reading of your answer is either:

* "I don't know of any code that will actually break, but I'd like to scare everybody anyway", or
* "I know of some code that will break, but I'm not going to go to the effort of telling you what the problem actually is"


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153916/new/

https://reviews.llvm.org/D153916



More information about the flang-commits mailing list