Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: bcc32.exe: Variables declaration order and dependencies with crashes


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 0
Mariusz Lisowski

Posts: 12
Registered: 2/28/06
bcc32.exe: Variables declaration order and dependencies with crashes  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 19, 2016 1:53 PM
Hi all,
Would you like help explain what is responsible for application crash when order of declarations is changed ?

I have souce like this:

int x = 0, j = 0, n = 0;
unsigned int subnet_size = 0, subnet_registered = 0, i = 0, end = 0;
 
const char *ptr1 = NULL;
const char *ptr2 = NULL;
const char *ptr3 = NULL;
const char *ptr4 = NULL;
const char *ptr5 = NULL;
 
end = zones[zone].subnet + zones[zone].subnets;
 
for (n = 0; n < LANGUAGES; n++)
	{
	fprintf(result_fptr[n],
			zone_header[n],
			zones[zone].description,
			zones[zone].addr_begin,
			zones[zone].addr_end,
			zones[zone].Koordynator_name,
			zones[zone].Koordynator_mail
			);
 
ptr1 = &zones[zone].description;
ptr2 = &zones[zone].addr_begin;
ptr3 = &zones[zone].addr_end;
ptr4 = &zones[zone].Koordynator_name;
ptr5 = &zones[zone].Koordynator_mail;
	printf( zone_header[n],
			ptr1,
			ptr2,
			ptr3,
			ptr4,
			ptr5
			);
 


When I build application no any warnings or errors - is clean :) an application run well. On first view all is correct.
When I change order of declarations application building runs well and finally is obtained exe file.


const char *ptr1 = NULL;
const char *ptr2 = NULL;
const char *ptr3 = NULL;
const char *ptr4 = NULL;
const char *ptr5 = NULL;
int x = 0, j = 0, n = 0;
unsigned int subnet_size = 0, subnet_registered = 0, i = 0, end = 0;
 
end = zones[zone].subnet + zones[zone].subnets;
 
for (n = 0; n < LANGUAGES; n++)
	{
	fprintf(result_fptr[n],
			zone_header[n],
			zones[zone].description,
			zones[zone].addr_begin,
			zones[zone].addr_end,
			zones[zone].Koordynator_name,
			zones[zone].Koordynator_mail
			);
 
ptr1 = &zones[zone].description;
ptr2 = &zones[zone].addr_begin;
ptr3 = &zones[zone].addr_end;
ptr4 = &zones[zone].Koordynator_name;
ptr5 = &zones[zone].Koordynator_mail;
	printf( zone_header[n],
			ptr1,
			ptr2,
			ptr3,
			ptr4,
			ptr5
			);
 


Build application crashes. Problem was tracked and I see that program crashes when is called fprinf() routine.
Do you know something about some rules of creating declarations or something similar ? I always thought that it isn't important which order is.

Best regards,
Mariusz
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02