C, Fortran, and single-character strings
C, Fortran, and single-character strings
Posted Jun 20, 2019 22:35 UTC (Thu) by imMute (guest, #96323)Parent article: C, Fortran, and single-character strings
I would argue that the code *wasn't* working before...
Posted Jun 21, 2019 7:19 UTC (Fri)
by ibukanov (subscriber, #3942)
[Link] (4 responses)
Posted Jun 21, 2019 12:35 UTC (Fri)
by nivedita76 (subscriber, #121790)
[Link] (2 responses)
Posted Jun 22, 2019 21:37 UTC (Sat)
by ncm (guest, #165)
[Link] (1 responses)
To pass an integer that is to be interpreted as an enumeration value, you also pass just a pointer. In Fortran, enumeration values are conventionally assigned character codes. They're not strings, they're just convenient literal notation for a symbol. Passing a pointer to a character is just the language idiom for an enumerated-value argument.
But passing a pointer to a character is not wrong or fragile code. Changing a library to fail without an extra length argument, after conventional usage is well-established, would be. If, in fact, maintainers of Fortran libraries are doing that, shame on THEM. I see no reason for C users of Fortran libraries to be embarrassed. Their code is not wrong or fragile, absent specific documentation of the original library to the contrary. Changing the compiler to forbid this usage would be wrong.
If you look at the libraries in question, you will probably find places where an argument interpreted as an enumerator is followed by another actual argument, where inserting another, length, argument would produce the wrong result, or a crash.
Posted Jun 24, 2019 5:47 UTC (Mon)
by joib (subscriber, #8541)
[Link]
Posted Jul 7, 2019 1:07 UTC (Sun)
by ericharris76 (guest, #132998)
[Link]
If the code had no comments and all its variable names were completely arbitrary and the indenting was missing or goofy, it would be "working" but not "right" or "good", even if the calling sequences were all standards-conforming and it always produced the right results, before and after the change to the compiler.
Posted Jun 21, 2019 11:22 UTC (Fri)
by mb (subscriber, #50428)
[Link] (3 responses)
Posted Jun 21, 2019 12:37 UTC (Fri)
by nivedita76 (subscriber, #121790)
[Link] (2 responses)
Posted Jun 22, 2019 10:21 UTC (Sat)
by Jandar (subscriber, #85683)
[Link]
This attitude is accepting reality and not naming something inconvenient fake facts. If something works than it works - fact. The goal isn't simply to get something to work, it is to get something to work safe and reliable. This distinction between simply working (maybe only backed by luck) and good engineering is the topic of the woodpecker comment.
Posted Jun 27, 2019 14:51 UTC (Thu)
by jschrod (subscriber, #1646)
[Link]
C, Fortran, and single-character strings
C, Fortran, and single-character strings
C, Fortran, and single-character strings
C, Fortran, and single-character strings
C, Fortran, and single-character strings
C, Fortran, and single-character strings
It was working code, if the definition was: "Get the actual job done."
Most people care about getting things done, not about ABI definitions.
C, Fortran, and single-character strings
C, Fortran, and single-character strings
C, Fortran, and single-character strings