home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / os / mswindo / programm / win32 / 2545 < prev    next >
Encoding:
Text File  |  1992-12-21  |  7.3 KB  |  252 lines

  1. Newsgroups: comp.os.ms-windows.programmer.win32
  2. Path: sparky!uunet!caen!hellgate.utah.edu!irit.cs.utah.edu!gershon
  3. From: gershon%irit.cs.utah.edu@cs.utah.edu (Elber Gershon)
  4. Subject: Re: NT October release C++ bugs
  5. Date: 18 Dec 92 15:57:54 MST
  6. Message-ID: <1992Dec18.155754.5036@hellgate.utah.edu>
  7. Organization: University of Utah CS Dept
  8. References: <1992Dec14.160558.7685@hellgate.utah.edu>
  9. Lines: 241
  10.  
  11. In article <1992Dec14.160558.7685@hellgate.utah.edu> gershon%irit.cs.utah.edu@cs.utah.edu (Elber Gershon) writes:
  12. >Below are several bugs in the C++ of the beta october release of window NT.
  13. >I would appreciate if someone can upload this to Compuserve as Microsoft
  14. >requests since I have no such access.
  15. >
  16. >    All small programs below fail on the NT C++ compiler but
  17. >succeed using unix AT&T 2.1/3.0 C++ as well as Sun and SGI C++ compiler.
  18. >All these small examples were extracted from a very large C++ project that
  19. >runs under unix for several years. All compiled in NT using 'cl -c -Tp file.c'.
  20. >
  21.     In continuation of the NT C++ bug list message I posted few days ago,
  22. here are some running time bugs and general programming questions in NT.
  23. Again I had appreciate if it can be forwarded to Compuserve/Microsoft.
  24.  
  25. * The following small program (compiled with the same flags as simple.c in
  26.   the sample directory in text mode) generates wrong code:
  27.  
  28.   #include <stdio.h>
  29.   
  30.     void main()
  31.     {
  32.         double d;
  33.         int i, j;
  34.     
  35.         for ( i=0; i<4; i++ ) {
  36.             for ( j=0; j<4; j++ ) {
  37.     /*
  38.                 if ( i == j )
  39.                     d = 1.0;
  40.                 else
  41.                     d = 0.0;
  42.     */
  43.                 d = (i == j) ? 1.0 : 0.0;
  44.     
  45.                 fprintf(stderr, "(%d, %d) = %lf\n", i, j, d);
  46.             }
  47.         }
  48.     }
  49.  
  50.   and the output is 
  51.  
  52.     (0, 0) = 0.000000
  53.     (0, 1) = 0.000000
  54.     (0, 2) = 0.000000
  55.     (0, 3) = 0.000000
  56.     (1, 0) = 0.000000
  57.     (1, 1) = 0.000000
  58.     (1, 2) = 0.000000
  59.     (1, 3) = 0.000000
  60.     (2, 0) = 0.000000
  61.     (2, 1) = 0.000000
  62.     (2, 2) = 0.000000
  63.     (2, 3) = 0.000000
  64.     (3, 0) = 0.000000
  65.     (3, 1) = 0.000000
  66.     (3, 2) = 0.000000
  67.     (3, 3) = 0.000000
  68.  
  69.   Surprisingly enough, '(i == j) ? 1.0 : 0.0;' is returning only zeros.
  70.   The equivalent 'if - then - else' that is commented out is o.k. Below
  71.   is the relevant Assembly code from the cod file:
  72.  
  73.     ; 10   : /*
  74.     ; 11   :            if ( i == j )
  75.     ; 12   :                d = 1.0;
  76.     ; 13   :            else
  77.     ; 14   :                d = 0.0;
  78.     ; 15   : */
  79.     ; 16   :            d = (i == j) ? 1.0 : 0.0;
  80.     
  81.       0003b 8b 45 f4        mov     eax, DWORD PTR _i$[ebp]
  82.       0003e 39 45 f0        cmp     DWORD PTR _j$[ebp], eax
  83.       00041 0f 85 07 00 00
  84.             00              jne     $L195
  85.       00047 d9 e8           fld1
  86.       00049 e9 0d 00 00 00  jmp     $L194
  87.     $L195:
  88.       0004e a1 04 00 00 00  mov     eax, DWORD PTR $T197+4
  89.       00053 89 45 fc        mov     DWORD PTR _d$[ebp+4], eax
  90.       00056 a1 00 00 00 00  mov     eax, DWORD PTR $T197
  91.     $L194:
  92.       0005b 89 45 f8        mov     DWORD PTR _d$[ebp], eax
  93.  
  94.   For i == j only half of the double 8 bytes are actually updated at all...
  95.  
  96. * Let class obj1type have no virtual function. Let class obj2type have
  97.   a virtual function and let obj2type inherit from obj1type. The following
  98.   code demonstrate such a possible situation.
  99.     
  100.     #include <stdio.h>
  101.     
  102.     class obj1type
  103.     {
  104.         unsigned        m_size;
  105.     
  106.       public:
  107.         obj1type( int s );
  108.         ~obj1type();
  109.     
  110.         void           *operator new( unsigned int s );
  111.         void        operator delete( void *mp );
  112.     
  113.     /*    virtual int       can_geometry_obj(); */
  114.     };
  115.     
  116.     class obj2type : public obj1type
  117.     {
  118.         void *t_tag;
  119.     
  120.       public:
  121.         obj2type( int s = 0 );
  122.         virtual int       can_geometry_obj();
  123.     };
  124.     
  125.     void *obj1type::operator new( unsigned int s )
  126.     {
  127.         void *ret = new char[s];
  128.     
  129.         fprintf(stderr, "Obj1type new, this = %x\n", ret);
  130.         return ret;
  131.     }
  132.     
  133.     obj1type::obj1type( int s )
  134.     {
  135.         fprintf(stderr, "Obj1type constructor, this = %x\n", this);
  136.     }
  137.     
  138.     obj2type::obj2type( int s ) : obj1type( s )
  139.     {
  140.         fprintf(stderr, "Obj2type constructor, this = %x\n", this);
  141.     }
  142.     
  143.     int obj2type::can_geometry_obj()
  144.     {
  145.         return 1;
  146.     }
  147.     
  148.     /*
  149.     int obj1type::can_geometry_obj()
  150.     {
  151.         return 1;
  152.     }
  153.     */
  154.     
  155.     void main()
  156.     {
  157.         obj2type *o = new obj2type( 5 );
  158.     }
  159.     
  160.   One would expect the pointer that is returned by Obj1type new operator to
  161.   be the same as the pointer that is passed to the Obj1type constructor as
  162.   happens when running this program under SGI C++:
  163.  
  164.     Obj1type new, this = 1000b674
  165.     Obj1type constructor, this = 1000b674
  166.     Obj2type constructor, this = 1000b674
  167.  
  168.   But running this program on NT C++ we get:
  169.  
  170.     Obj1type new, this = 131f90
  171.     Obj1type constructor, this = 131f94
  172.     Obj2type constructor, this = 131f90
  173.  
  174.   I can only suspect that a virtual table pointer consumed the 4 missing bytes
  175.   but when the user wrote his new method he ignores this pointer and allocates
  176.   enough bytes for his slots excluding this virtual table, and more
  177.   interestingly why then Obj2type got the original pointer back?
  178.   Making Obj1type having a virtual method (and table), by un-commenting
  179.   the above commented code, "fix" the problem.
  180.  
  181. * How one make the system's pipe work in binary mode. I can set stdin/out
  182.   to work in binary mode (using setmode or fdopen) but this is what is
  183.   happening.
  184.  
  185.   I can do
  186.  
  187.     program1.exe > binary_data
  188.  
  189.   and
  190.  
  191.     program2.exe < binary_data
  192.  
  193.   but I cannot do
  194.  
  195.     program1.exe | program2.exe
  196.  
  197.   Any idea?
  198.  
  199. * I am getting the following messages from the linker.
  200.  
  201.         lib -out:O.lib *.obj
  202.     Microsoft(R) Windows NT Librarian Version 2.19
  203.     (C) 1989-1992 Microsoft Corp. All rights reserved.
  204.  
  205.     OH_features.obj() : error 0123: Can't convert object to Windows NT format
  206.     Extended Error: No such file or directory
  207.  
  208.     cvtomf() : error : Too many SEGDEF/COMDAT records
  209.  
  210.   Obviously OH_features.c was compiled with Windows NT C++ compiler (with no
  211.   warnings/errors). Looks like I am overflowing some internal table. Any
  212.   way to fix this?
  213.  
  214. *      lib -out:SP.lib bspline\*.obj mspl\*.obj tess\*.obj
  215.   Microsoft(R) Windows NT Librarian Version 2.19
  216.   (C) 1989-1992 Microsoft Corp. All rights reserved.
  217.  
  218.   bspline\is_srf.obj ()() : warning 0506: ?is_srf_open@@YAHPAUsrf_obj@@@Z multiply defined, defined in bspline\blk_eval.obj ()
  219.   
  220.   There is no is_srf_open in blk_eval.c, only in is_srf.c.
  221.  
  222. * How can one un-mangle the names printed by lib/link/coff -Dump:
  223.   
  224.   render_defs.obj() : warning 0506: ??0trace_hash_table_type@@QAG@XZ multiply defined, defined in render.obj
  225.  
  226.   so far I have deciphered the following:
  227.  
  228.   ??0* - a constructor
  229.   ??1* - destructor (!?)
  230.   ??2* - a new method
  231.   ??3* - a delete method
  232.  
  233. * Annoying bugs in WinDbg.
  234.   1. Source files in unix format (that is no CRLF, just LF) cannot be read
  235.      into the debugger even though the compiler handles them with no problem.
  236.      Getting a "not text file" error. In NTSD the lines are off if only LF.
  237.   2. 'windbg abcdefgh.exe' is ok but 'windbg abcdefghi.exe' is not. In other
  238.      words, still in the MSDOS 8.3 file name conventions. I can read long
  239.      names from the Program/Load menu with no problem though.
  240.  
  241. * How do one view local variables in WinDbg or ntsd (. does not work).
  242.   Relevant help does not exists, and intuition (mine at least) was not
  243.   helpful...
  244.  
  245. thanks
  246.  
  247. Gershon
  248. /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  249. Gershon Elber                            gershon@cs.utah.edu
  250. Computer Science Department              Fax: (801) 581-5843
  251. University of Utah 84112                 Tel: (801) 585-5635
  252.