Optimization considered harmful 
Author Message
 Optimization considered harmful

Quote:

>I have included a program below which is broken by the Microsoft 6.0
>compiler on MSDOS.   While this is no great surprise, ...
>    if ((s_array = (STRING **)malloc(100 * sizeof(STRING))) == NULL) {

------------------------------------------------------^^^^^^
Should be STRING *.

Quote:
>            if ((s_array[i]->s = (char *)malloc(10)) == NULL) {

----------------------------------------------------^^
Should be 10 * sizeof(char), in order to get the right argument type.

Quote:
>}

Should be preceded by return 0;.

Quote:
>Now, which of the following lessons should be drawn from this event:
>    1) Don't use "register."
>    2) Don't use optimizers (or in this case be sure to disable optimizer).
>    3) Don't use "improved" Microsoft products.

        0) Make sure the code is supposed to work before looking elsewhere.
Assuming that fixing the code doesn't solve the problem, then
        4) Report the bug to the vendor and devise a work-around.

I can't recommend any of alternatives 1-3.



Sun, 25 Apr 1993 18:18:36 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Optimization considered harmful

2. Hungarian Notation Can be Considered Harmful (was Re: GCC/G++ vs Other guys)

3. cast considered harmful?

4. break considered harmful

5. strcat() considered harmful

6. Gotos considered harmful (Dijkstra vs. Knuth )

7. EOF considered harmful

8. bitfields considered harmful?

9. C Problem (or, GOTOs considered harmful)

10. Variable Initialisation Considered Harmful ?

11. Mixed prototyping considered harmful

12. GOTO considered harmful

 

 
Powered by phpBB® Forum Software