[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::decc_bugs

Title:DEC C Problem Reporting Forum
Notice:Report DEC C++ problems in TURRIS::C_PLUS_PLUS
Moderator:CXXC::REPETETCHEON
Created:Fri Nov 13 1992
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1299
Total number of notes:6249

1275.0. "BUG with /STAND=VAXC (V5.5)." by UTRTSC::DORLAND (The Wizard of Odz2) Tue Mar 18 1997 07:12

	Hello,
    
    	we just found a bug in DECC 5.5, especially
    	when using /STANDARD=VAXC.
    
    	The program below reports correctly
    	that field1 is not a member of t_struct4;
    	however, wehn you compile with /STANDARD=VAXC
    	no error is reported.
    
    	If you comment out the typedef struct's
    	for t_struct1 and t_struct2 then also
    	/STAND=VAXC correctly reports the NOTMEMBER 
    	error.
    
    	This clearly looks like a bug.
    
    	Rgds, 
    
    	Ton Dorland
    
    
    
#include "stdio.h"
#include "string.h"
#include "stdlib.h"

typedef struct a_struct1 {
        char field1[20];
        } t_struct1;

typedef struct a_struct2 {
        t_struct1 field2;
        } t_struct2;

typedef struct a_struct3 {
        char field3[50];
        } t_struct3;

typedef struct a_struct4 {
        t_struct3 field4;
        } t_struct4;

void init_structure(t_struct4 *vp_struct)
{
/* The next statement incorrectly compiles oke
    when using /STAND=VAXC */
  memset(&vp_struct->field1, 0, sizeof(t_struct3));
}

int main(int argc,char *argv[],char *env[])
{
  t_struct4 vl_struct;

  init_structure(&vl_struct);
}
    
T.RTitleUserPersonal
Name
DateLines
1275.1featureCXXC::ZAHAREELinda D. ZahareeTue Mar 18 1997 11:2820
    Actually, this is a feature.  Old C behavior allowed you to use members
    of other structures or unions.  When doing this, the other structure 
    member's offset and type are used.  This is DECC's behavior in both 
    common and vaxc modes.
    
    When compiling your program in vaxc mode you should have seen the
    following diagnostic:
    
    $ cc/stand=vaxc decc_bugs_1275.c
    
      memset(&vp_struct->field1, 0, sizeof(t_struct3));
    ..........^
    %CC-I-OTHERMEMBER, In this statement, "field1" is a member of another
    struct or union.
    at line number 34 in file C2$:[ZAHAREE.TEMP]DECC_BUGS_1275.C;3
    
    This tells you that "field1" was not a member of the structure
    "vp_struct", but came from another structure.
    
    Linda.
1275.2Sorry but I don't agreeUTRTSC::DORLANDThe Wizard of Odz2Wed Mar 19 1997 12:3017
    I am puzzled. I have a pointer (vp_field) to a structure called 
    t_struct4.
    I try to perform something with a field (vp_struct->whatsoever).
    Whatsoever is not defined anywhere in t_struct4. So this is
    a clear error. The fact that whatsoever is used in a totally
    different structure should not make any difference.
    Try to run this program , and it will give problems whenever
    you do something with vp_field->whatsoever. 
    
    Also, there is a difference between VAX and Alpha, on Alpha
    you don't get even an informational when using /STAND=VAXC.
    (Tested with V5.5 on both Alpha and VAX).
    
    I still think the compiler should definitely give an error
    on this statement.
    
    Regards 
1275.3DECC::ZAHAREELinda D. ZahareeWed Mar 19 1997 12:5234
    Well, I can't say I really like the feature either, but since
    traditional C compilers did this, DECC was forced to support
    it in the appropriate modes.
    
    I'm not sure why you're not seeing the informational on Alpha.
    When I try it, I do.  Maybe you have informationals turned off?
    
    Here's what I get on Alpha:
    
      $ cc/version decc_bugs_1275.c
      DEC C V5.5-002 on OpenVMS Alpha V6.2-1H3
      $ cc/stand=vaxc decc_bugs_1275.c
    
        memset(&vp_struct->field1, 0, sizeof(t_struct3));
      ..........^
      %CC-I-OTHERMEMBER, In this statement, "field1" is a member of another struct or union.
      at line number 34 in file C2$:[ZAHAREE.TEMP]DECC_BUGS_1275.C;3
    
    Here's what I get on VAX:
    
      $ cc/version decc_bugs_1275.c
      DEC C V5.5-002 on OpenVMS VAX V6.2
      $ cc/stand=vaxc decc_bugs_1275.c
                memset(&vp_struct->field1, 0, sizeof(t_struct3));
              ..........^
      %CC-I-OTHERMEMBER, In this statement, "field1" is a member of another struct or
       union.
                    At line number 34 in C2$:[ZAHAREE.TEMP]DECC_BUGS_1275.C;3.
    
      %VCG-I-SUMMARY, Completed with 0 error(s), 0 warning(s), and
                      1 informational messages.
                      At line number 43 in C2$:[ZAHAREE.TEMP]DECC_BUGS_1275.C;3.
    
    Linda.
1275.4version is 7.1...UTRTSC::DORLANDThe Wizard of Odz2Thu Mar 20 1997 07:4410
    Well , I am running VMS 7.1 on the Alpha so that may make difference:
    
    $ cc/version bug
    DEC C V5.5-002 on OpenVMS Alpha V7.1    
    $ cc/stand=vaxc bug
    $
    
    Ton Dorland
    
    
1275.5VMS version shouldn't affect thisWIBBIN::NOYCEPulling weeds, pickin' stonesThu Mar 20 1997 11:103
What does  $SHOW SYMBOL CC  show?

You haven't done a  $SET MESSAGE/NOFAC/NOID/NOSEV/NOTEXT , have you?
1275.6Why are you using /STAND=VAXC?DECC::VOGELThu Mar 20 1997 14:1412
    
    To add to what Linda has said:  When you specify /STAND=VAXC then
    the compiler will try to do exactly what VAX C did.  In cases
    such as this, VAX C would issue an informational message and compile
    the program.  The DEC C V5.5 behavior matches that.  
    
    Why are you using /STAND=VAXC?  If you do not use it, you'll get
    the error you expect. 
    
    						Ed