Hi Folks. It's me again.
Some programming languages such as C sharp for example, support
software engineering principles such as detection of attempts
to use uninitialized variables, and ensure programs with unsafe
code must have appropriate permission to run. So, I tested my
Net Express COBOL compiler on these basic programming principles.
I moved an alphabetic string variable to a numeric variable.
the compiler did not raise a flag. It simply compiled the code,
produced an executable program and ran it. Here are my questions:
1). Why the COBOL compiler does not raise a red flag when you move
an alphabetic string to a numeric variable?
2). Do other programming languages compilers raise a red flag when
an alphabetic string is moved to a numeric variable?
3). Why compilers are not designed to ensure the importance of
programmers productivity and to safe guard against such
flagrant, serious and naked software bugs?
Your feedback is very much appreciated.
COBOL - the elephant that can stand on its trunk...
Hi Folks. It's me again.
Some programming languages such as C sharp for example, support
software engineering principles such as detection of attempts
to use uninitialized variables, and ensure programs with unsafe
code must have appropriate permission to run. So, I tested my
Net Express COBOL compiler on these basic programming principles.
I moved an alphabetic string variable to a numeric variable.
the compiler did not raise a flag. It simply compiled the code,
produced an executable program and ran it. Here are my questions:
1). Why the COBOL compiler does not raise a red flag when you move
an alphabetic string to a numeric variable?
2). Do other programming languages compilers raise a red flag when
an alphabetic string is moved to a numeric variable?
3). Why compilers are not designed to ensure the importance of--- Synchronet 3.20a-Linux NewsLink 1.114
programmers productivity and to safe guard against such
flagrant, serious and naked software bugs?
Your feedback is very much appreciated.
On 5/14/2018 11:42 AM, Clark F Morris wrote:
On Mon, 14 May 2018 08:09:35 -0700 (PDT), Kellie Fitton
<[email protected]> wrote:
Some programming languages such as C sharp for example, support
software engineering principles such as detection of attempts
to use uninitialized variables, and ensure programs with unsafe
code must have appropriate permission to run. So, I tested my
Net Express COBOL compiler on these basic programming principles.
I moved an alphabetic string variable to a numeric variable.
the compiler did not raise a flag. It simply compiled the code,
produced an executable program and ran it. Here are my questions:
Which compiler? I am fairly certain that the IBM compilers would flag
a PIC X to PIC 9 MOVE and probably fail the compilation. I don't have
a system available to me to verify this.
Clark Morris
1). Why the COBOL compiler does not raise a red flag when you move
an alphabetic string to a numeric variable?
2). Do other programming languages compilers raise a red flag when
an alphabetic string is moved to a numeric variable?
3). Why compilers are not designed to ensure the importance of
programmers productivity and to safe guard against such
flagrant, serious and naked software bugs?
Your feedback is very much appreciated.
COBOL - the elephant that can stand on its trunk...
I just tested this on IBM COBOL FOR VSE/ESA 1.1.1
The compiler does not flag the move of PIC X to PIC 9. Here is a sample output I cobbled together to summarize what happens in a couple of cases:
SOURCE-FIELD 12345
DEST-FIELD 12345
SOURCE-FIELD ABCDE
DEST-FIELD ABCD5
Here is the code (at least relevant bits):
WORKING-STORAGE SECTION.
01 FILLER.
05 SOURCE-FIELD PIC X(5).
05 DEST-FIELD PIC 9(5).
PROCEDURE DIVISION.
0000-MAINLINE.
MOVE '12345' TO SOURCE-FIELD
MOVE SOURCE-FIELD TO DEST-FIELD
DISPLAY 'SOURCE-FIELD ' SOURCE-FIELD
DISPLAY ' DEST-FIELD ' DEST-FIELD
MOVE 'ABCDE' TO SOURCE-FIELD
MOVE SOURCE-FIELD TO DEST-FIELD
DISPLAY 'SOURCE-FIELD ' SOURCE-FIELD
DISPLAY ' DEST-FIELD ' DEST-FIELD
.
9000-END.
STOP RUN
.
I think the COBOL manuals explicitly state what happens in these mixed situations and indeed a LOT of old code is written to depend on that specific sort of behaviour...
SOURCE-FIELD 12345
DEST-FIELD 12345
SOURCE-FIELD ABCDE
DEST-FIELD ABCD5
| Sysop: | DaiTengu |
|---|---|
| Location: | Appleton, WI |
| Users: | 1,123 |
| Nodes: | 10 (0 / 10) |
| Uptime: | 37:32:07 |
| Calls: | 14,371 |
| Files: | 186,380 |
| D/L today: |
3,842 files (1,077M bytes) |
| Messages: | 2,540,675 |