This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: egcs, warning patches


 > From: Carlo Wood <carlo@runaway.xs4all.nl>
 > 
 > | 	Here's a minor set of warning patches. 
 > ...
 > | -  lang_get_alias_set = &c_get_alias_set;
 > | +  lang_get_alias_set = c_get_alias_set;
 > ...
 > | -		bzero ((char *) &reg_data->data,
 > | +		bzero ((char *) reg_data->data,
 > |  		       sizeof (reg_info) * (max - min_index + 1));
 > 
 > I wouldn't call these "warning patches", if these changes are
 > correct, they are terrible-bug fixes.
 > -- 
 >  Carlo Wood  <carlo@runaway.xs4all.nl>



	(I've cc:ed Mike since I believe he installed the regclass.c
code on July 2 according to the ChangeLog entries.  Mike, my original
posting is at: http://www.cygnus.com/ml/egcs-patches/1998-Jul/0217.html)



	Carlo, I can assure you that in both cases I get warnings
claiming that these ampersands are ignored and that removing them does
not change the behavior of the program.  However, that's not to say
that the program itself is correct. :-)

 > (from SunOS4 cc)
 > cc -c -DIN_GCC -g -DHAVE_CONFIG_H -DHAIFA -I. -I. -I./config c-decl.c
 > "c-decl.c", line 3525: warning: & before array or function: ignored
 > [...]
 > cc -c -DIN_GCC -g -DHAVE_CONFIG_H -DHAIFA -I. -I. -I./config regclass.c
 > "regclass.c", line 1877: warning: & before array or function: ignored



	The first one is pretty clearly right since c_get_alias_set is
a function pointer.

	In second case, the structure member `data' is an array of
size one defined within the containing structure reg_info_data.  (I've
listed the definitions copied from regclass.c and regs.h below.)  The
expression "reg_data->data" and "& reg_data->data" evaluate to the
same address in memory in the call to bzero.

	However looking more closely at the logic of the statement, I'm
not 100% sure that its correct.  The clearing of memory for member
`data' seems to wipe more than one element, so it looks like the size
parameter to bzero is not correct.  Or something more fundamental is
wrong, like programming confusion as to whether member `data' is a fixed
sized array or a dynamically allocated one. 

	Mike, would you please comment?

		Thanks,
		--Kaveh	




/* Register information indexed by register number */
typedef struct reg_info_def {
                                /* fields set by reg_scan */
  int first_uid;                /* UID of first insn to use (REG n) */
  int last_uid;                 /* UID of last insn to use (REG n) */
  int last_note_uid;            /* UID of last note to use (REG n) */

                                /* fields set by both reg_scan and flow_analysi\
s */
  int sets;                     /* # of times (REG n) is set */

                                /* fields set by flow_analysis */
  int refs;                     /* # of times (REG n) is used or set */
  int deaths;                   /* # of times (REG n) dies */
  int live_length;              /* # of instructions (REG n) is live */
  int calls_crossed;            /* # of calls (REG n) is live across */
  int basic_block;              /* # of basic blocks (REG n) is used in */
  char changes_size;            /* whether (SUBREG (REG n)) changes size */
} reg_info;

/* Linked list of reg_info structures allocated for reg_n_info array.
   Grouping all of the allocated structures together in one lump
   means only one call to bzero to clear them, rather than n smaller
   calls.  */
struct reg_info_data {
  struct reg_info_data *next;   /* next set of reg_info structures */
  size_t min_index;             /* minimum index # */
  size_t max_index;             /* maximum index # */
  char used_p;                  /* non-zero if this has been used previously */
  reg_info data[1];             /* beginning of the reg_info data */
};

struct reg_info_data *reg_data;
--
Kaveh R. Ghazi			Project Manager / Custom Development
ghazi@caip.rutgers.edu		Icon CMT Corp.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]