|
Sorry. Although I posted this message C54x group already, I thought this group may be proper me to ask this question. So I copy the message. ----- Hi, I encountered the warning message like below. "warning: pointer points outside of underlying object" The code which generate the warning message is below : int global_var = 5; int main(){ long int t; printf("0x%lx\n", 0x10000 + ((long int)&global_var)); } This didn't work as I expected. The printed value is not correct. What's the warning message? Strangely, I could avoid the warning when I modified the code slightly like below. int global_var = 5; int main(){ long int t; printf("0x%lx\n", 0x10000 + (t=(long int)&global_var)); } In this case, the CCS didn't generate the warning message and I could see the correct printed value. Any comment or idea? Best Regards, KT |
|
|
|
KT Rhee- > I encountered the warning message like below. > > "warning: pointer points outside of underlying object" > > The code which generate the warning message is below : > > int global_var = 5; > int main(){ > long int t; > printf("0x%lx\n", 0x10000 + ((long int)&global_var)); > } > > This didn't work as I expected. The printed value is not correct. > What's the warning message? > > Strangely, I could avoid the warning when I modified the code > slightly like below. > > int global_var = 5; > int main(){ > long int t; > printf("0x%lx\n", 0x10000 + (t=(long int)&global_var)); > } > > In this case, the CCS didn't generate the warning message and I could > see the correct printed value. If this is C54x code, then int is 16-bit and long int is 32-bit. Your first example writes past length of global_var -- something gets stepped on. Hope that explains it. -Jeff |
|
KT Rhee- > I encountered the warning message like below. > > "warning: pointer points outside of underlying object" > > The code which generate the warning message is below : > > int global_var = 5; > int main(){ > long int t; > printf("0x%lx\n", 0x10000 + ((long int)&global_var)); > } > > This didn't work as I expected. The printed value is not correct. > What's the warning message? > > Strangely, I could avoid the warning when I modified the code > slightly like below. > > int global_var = 5; > int main(){ > long int t; > printf("0x%lx\n", 0x10000 + (t=(long int)&global_var)); > } > > In this case, the CCS didn't generate the warning message and I could > see the correct printed value. If this is C54x code, then int is 16-bit and long int is 32-bit. Your first example writes past length of global_var -- something gets stepped on. Hope that explains it. -Jeff |
|
> Any comment or idea? Submit a bug report to either <> or <>. Syntactically, the program (both instances) is absolutely valid. It compiles fine with other compilers, including those that have different size for all, pointers, ints, long ints. The bug seem to be quite arbitrary, is there a chance that 0x10000L for "long int" might improve the situation? -- Andrew > Date: Tue, 10 Feb 2004 02:47:06 -0000 > From: "kt_rhee" <> > Subject: warning: pointer points outside of underlying object > > Sorry. Although I posted this message C54x group already, I thought > this group may be proper me to ask this question. So I copy the > message. > > ----- > > Hi, > > I encountered the warning message like below. > > "warning: pointer points outside of underlying object" > > The code which generate the warning message is below : > > int global_var = 5; > int main(){ > long int t; > printf("0x%lx\n", 0x10000 + ((long int)&global_var)); > } > > This didn't work as I expected. The printed value is not correct. > What's the warning message? > Strangely, I could avoid the warning when I modified the code > slightly like below. > > int global_var = 5; > int main(){ > long int t; > printf("0x%lx\n", 0x10000 + (t=(long int)&global_var)); > } > > In this case, the CCS didn't generate the warning message and I could > see the correct printed value. > > Any comment or idea? > > Best Regards, > KT |
|
Andrew- > Submit a bug report to either <> or <>. > > Syntactically, the program (both instances) is absolutely > valid. It compiles fine with other compilers, including those > that have different size for all, pointers, ints, long ints. > > The bug seem to be quite arbitrary, is there a chance that > 0x10000L for "long int" might improve the situation? The bug is in KT's code. He said he was using C54x, which means he's either reading undefined memory (best case) or overwriting it (worst case, depending on what the compiler does). Please see my earlier post. -Jeff > Andrew > > > Date: Tue, 10 Feb 2004 02:47:06 -0000 > > From: "kt_rhee" <> > > Subject: warning: pointer points outside of underlying object > > > > Sorry. Although I posted this message C54x group already, I thought > > this group may be proper me to ask this question. So I copy the > > message. > > > > ----- > > > > Hi, > > > > I encountered the warning message like below. > > > > "warning: pointer points outside of underlying object" > > > > The code which generate the warning message is below : > > > > int global_var = 5; > > int main(){ > > long int t; > > printf("0x%lx\n", 0x10000 + ((long int)&global_var)); > > } > > > > This didn't work as I expected. The printed value is not correct. > > What's the warning message? > > > > > > Strangely, I could avoid the warning when I modified the code > > slightly like below. > > > > int global_var = 5; > > int main(){ > > long int t; > > printf("0x%lx\n", 0x10000 + (t=(long int)&global_var)); > > } > > > > In this case, the CCS didn't generate the warning message and I could > > see the correct printed value. > > > > Any comment or idea? > > > > Best Regards, > > KT > > > > _____________________________________ > Yahoo! Groups Links |
|
Hi Jeff & Andrew,
Thanks for you comments. By the way, I cannot figure out
Jeff's. I just hoped to get the value, the address of global_var plus 0x10000. Please tell me
in detail about "undefined memory" and "overwriting it." Furtheremore, what's the difference
between the first code and the second code?
About the 0x10000L, that makes no difference,
Andrew.
KT
----- Original Message -----
From: Jeff Brower
To: Andrew Nesterov
Cc: c...@yahoogroups.com
Sent: Wednesday, February 11, 2004 5:47 AM
Subject: Re: [code-comp] Re: warning: pointer points outside of underlying
object > Submit a bug report to either <e...@ti.com> or <t...@ti.com>. > > Syntactically, the program (both instances) is absolutely > valid. It compiles fine with other compilers, including those > that have different size for all, pointers, ints, long ints. > > The bug seem to be quite arbitrary, is there a chance that > 0x10000L for "long int" might improve the situation? The bug is in KT's code. He said he was using C54x, which means he's either reading undefined memory (best case) or overwriting it (worst case, depending on what the compiler does). Please see my earlier post. -Jeff > Andrew > > > Date: Tue, 10 Feb 2004 02:47:06 -0000 > > From: "kt_rhee" <k...@clipcomm.co.kr> > > Subject: warning: pointer points outside of underlying object > > > > Sorry. Although I posted this message C54x group already, I thought > > this group may be proper me to ask this question. So I copy the > > message. > > > > ----- > > > > Hi, > > > > I encountered the warning message like below. > > > > "warning: pointer points outside of underlying object" > > > > The code which generate the warning message is below : > > > > int global_var = 5; > > int main(){ > > long int t; > > printf("0x%lx\n", 0x10000 + ((long int)&global_var)); > > } > > > > This didn't work as I expected. The printed value is not correct. > > What's the warning message? > > > > > > Strangely, I could avoid the warning when I modified the code > > slightly like below. > > > > int global_var = 5; > > int main(){ > > long int t; > > printf("0x%lx\n", 0x10000 + (t=(long int)&global_var)); > > } > > > > In this case, the CCS didn't generate the warning message and I could > > see the correct printed value. > > > > Any comment or idea? > > > > Best Regards, > > KT > > > > _____________________________________> Yahoo! Groups Links> > _____________________________________ |
|
Hi, About the warning message, I got the below mail from TI technical support. Please refer to below. ---- Hello Kay, This is regarding case 35342600 opened with TI Customer Support for the following problem: "Compiler generates warning for printf("0x%lx\n", 0x10000 + ((long int)&global_var)); as follows: "warning: pointer points outside of underlying object" and the code does not execute correctly." I was able to reproduce this behaviour of the tool on CCS2.2. I have filed bug report SDSsq35431 for reporting this behaviour. The concerned engineers will be analyzing this bug report and taking the necessary action so that the bug can be fixed in a future version of the tool. Thank you for reporting this issue to us. ----- KT. ----- Original Message ----- From: Kyungtae Lee To: Andrew Nesterov ; Jeff Brower Cc: Sent: Wednesday, February 11, 2004 10:11 AM Subject: Re: [code-comp] Re: warning: pointer points outside of underlying object Hi Jeff & Andrew, Thanks for you comments. By the way, I cannot figure out Jeff's. I just hoped to get the value, the address of global_var plus 0x10000. Please tell me in detail about "undefined memory" and "overwriting it." Furtheremore, what's the difference between the first code and the second code? About the 0x10000L, that makes no difference, Andrew. KT ----- Original Message ----- From: Jeff Brower To: Andrew Nesterov Cc: Sent: Wednesday, February 11, 2004 5:47 AM Subject: Re: [code-comp] Re: warning: pointer points outside of underlying object Andrew- > Submit a bug report to either <> or <>. > > Syntactically, the program (both instances) is absolutely > valid. It compiles fine with other compilers, including those > that have different size for all, pointers, ints, long ints. > > The bug seem to be quite arbitrary, is there a chance that > 0x10000L for "long int" might improve the situation? The bug is in KT's code. He said he was using C54x, which means he's either reading undefined memory (best case) or overwriting it (worst case, depending on what the compiler does). Please see my earlier post. -Jeff > Andrew > > > Date: Tue, 10 Feb 2004 02:47:06 -0000 > > From: "kt_rhee" <> > > Subject: warning: pointer points outside of underlying object > > > > Sorry. Although I posted this message C54x group already, I thought > > this group may be proper me to ask this question. So I copy the > > message. > > > > ----- > > > > Hi, > > > > I encountered the warning message like below. > > > > "warning: pointer points outside of underlying object" > > > > The code which generate the warning message is below : > > > > int global_var = 5; > > int main(){ > > long int t; > > printf("0x%lx\n", 0x10000 + ((long int)&global_var)); > > } > > > > This didn't work as I expected. The printed value is not correct. > > What's the warning message? > > > > > > Strangely, I could avoid the warning when I modified the code > > slightly like below. > > > > int global_var = 5; > > int main(){ > > long int t; > > printf("0x%lx\n", 0x10000 + (t=(long int)&global_var)); > > } > > > > In this case, the CCS didn't generate the warning message and I could > > see the correct printed value. > > > > Any comment or idea? > > > > Best Regards, > > KT > > > > _____________________________________ > Yahoo! Groups Links _____________________________________ _____________________________________ Yahoo! Groups Sponsor ADVERTISEMENT -------------------------------------------------------------------------------- Yahoo! Groups Links a.. To |
|
KT Lee- > About the warning message, I got the below mail from TI technical > support. Please refer to below. > > ---- > Hello Kay, > > This is regarding case 35342600 opened with TI Customer Support for the following problem: "Compiler generates warning for printf("0x%lx\n", 0x10000 + ((long int)&global_var)); as follows: "warning: pointer points outside of underlying object" and the code does not execute correctly." > > I was able to reproduce this behaviour of the tool on CCS2.2. I have filed bug report SDSsq35431 for reporting this behaviour. > > The concerned engineers will be analyzing this bug report and taking the necessary action so that the bug can be fixed in a future version of the tool. > > Thank you for reporting this issue to us. I'm not sure if you missed my earlier mail, but just in case, I will emphasize that the above "report" from TI does mean you have discovered a bug in the compiler. You still have a code issue that you should try to understand. If you were working for me, I definitely would not let you off the hook with that answer from TI :-) My answer repeated from earlier this morning below. -Jeff This is a customer support engineer reporting your incident, not a CCS design engineer. I doubt it will be changed in any future version of CCS. The issue still is: you are on C54x under CCS, only 16-bit pointers are supported. When you type cast a 16-bit pointer to a "long int" what are you doing? Will that produce a defined value? Is there a possibility a negative value will cause incorrect pointer arithmetic? Maybe the compiler is trying to tell you something :-) It's not unlike a warning like "conversion between incompatible types; some data may be lost", or similar. Did you try (unsigned long int) typecast? Does it have the same result? -Jeff |
|
Hi Jeff,
Thanks for your interests. I missed your previous
comment. :-$
Detaily speaking, the thing I want to do is to pass an
address as a function argument. The address points the extended program memory, i.e., 0x18000.
(I need to fetch some codes from the extended program memory to the internam memory
dynamically, that is, dynamic code swapping.)
On testing some ways to point the memory I want, I found
the bug. You may know "LOAD_START" keyword used in
.cmd file. When I used "LOAD_START(_load_addr)" in .cmd file, I can just refer lower 16 bit
address with "load_addr" in my .c file. (I guess, because only 16-bit pointers are supported.)
So, to access an extended area, I cannot help using "0x10000+(long int)&load_addr." (Apart
from this issue, is there any smart way to do what I want?)
In my thought, it is not a problem related to the
negative address, or incorrect type conversion, etc. And typecast with "unsigned long int"
makes the same result.
If the issue is resolved, I can do my work more smartly.
So, I also want to resolve this issue. If you have any comments or advices, let me know. Any
idea about my experiment(including code swapping) is welcomed. Thanks.
KT.
p.s.
Between you and me, please don't tell this to my boss.
;-)
----- Original Message -----
From: Jeff
Brower
To: Kyungtae
Lee
Cc: c...@yahoogroups.com ; c...@yahoogroups.com
Sent: Friday, February 13, 2004 12:59 AM
Subject: Re: [code-comp] Re: warning: pointer points
outside of underlying object > About the warning message, I got the below mail from TI technical > support. Please refer to below. > > ---- > Hello Kay, > > This is regarding case 35342600 opened with TI Customer Support for the following problem: "Compiler generates warning for printf("0x%lx\n", 0x10000 + ((long int)&global_var)); as follows: "warning: pointer points outside of underlying object" and the code does not execute correctly." > > I was able to reproduce this behaviour of the tool on CCS2.2. I have filed bug report SDSsq35431 for reporting this behaviour. > > The concerned engineers will be analyzing this bug report and taking the necessary action so that the bug can be fixed in a future version of the tool. > > Thank you for reporting this issue to us. I'm not sure if you missed my earlier mail, but just in case, I will emphasize that the above "report" from TI does mean you have discovered a bug in the compiler. You still have a code issue that you should try to understand. If you were working for me, I definitely would not let you off the hook with that answer from TI :-) My answer repeated from earlier this morning below. -JeffThis is a customer support engineer reporting your incident, not a CCS design engineer. I doubt it will be changed in any future version of CCS. The issue still is: you are on C54x under CCS, only 16-bit pointers are supported. When you type cast a 16-bit pointer to a "long int" what are you doing? Will that produce a defined value? Is there a possibility a negative value will cause incorrect pointer arithmetic? Maybe the compiler is trying to tell you something :-) It's not unlike a warning like "conversion between incompatible types; some data may be lost", or similar. Did you try (unsigned long int) typecast? Does it have the same result? -Jeff _____________________________________ |