Frank Everest
Junior Member
- Total Posts : 103
- Reward points : 0
- Joined: 2006/09/24 04:07:59
- Location: Stevenage, UK
- Status: offline
"warning: (759) expression generates no code" WHY?
I'm running MPLABX v5.45, and XC8 v2.31 compiler with the PRO dongle. The processor is 16F18254. The two variables divisor and dividend are both __int24's. time_to_go is an unsigned int. The lines are part of a function, and I get the above (759) warning at line 101. It says: sums.c:101:: warning: (759) expression generates no code sums.c:103:: warning: (760) portion of expression has no effect ... 100 if (divisor == 0) //catch division by zero: 101 time_to_go = 1990; 102 else 103 time_to_go = (unsigned int)(dividend/divisor); Now I really want to be sure to catch division by zero, and can't see what's wrong with line 103 either. Can anyone steer me onto the right path, please?
|
du00000001
Just Some Member
- Total Posts : 4071
- Reward points : 0
- Joined: 2016/05/03 13:52:42
- Location: Germany
- Status: offline
Re: "warning: (759) expression generates no code" WHY?
2020/11/28 08:54:37
(permalink)
Let me guess: time_to_go is currently read/used nowhere. So, why should an optimizing compiler compute a variable that's never read?
PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
|
Frank Everest
Junior Member
- Total Posts : 103
- Reward points : 0
- Joined: 2006/09/24 04:07:59
- Location: Stevenage, UK
- Status: offline
Re: "warning: (759) expression generates no code" WHY?
2020/11/28 09:06:28
(permalink)
You guess right! Doh. I've got the same code in two places with different target registers. sad:  That'll teach me to use legacy code (of mine) without noticing that. It's a good thing someone's awake! Thanks for spotting that.
|
du00000001
Just Some Member
- Total Posts : 4071
- Reward points : 0
- Joined: 2016/05/03 13:52:42
- Location: Germany
- Status: offline
Re: "warning: (759) expression generates no code" WHY?
2020/11/28 09:40:14
(permalink)
"Spotting that" is great - considering that you didn't provide more than this snippet of code. But the "generates no code" is a frequent "issue". Re: "... someone's awake ..." This is the w-w-w - somebody is always awake. It's 17.30 h local time (CET) :)
PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
|
AndersG
Super Member
- Total Posts : 241
- Reward points : 0
- Joined: 2008/08/05 04:51:24
- Location: 0
- Status: offline
Re: "warning: (759) expression generates no code" WHY?
2020/11/28 10:35:25
(permalink)
He, he. Just popped in to complain about this.. Ie: void foo(void) { int bar = 0; .. more code } I assume that it flags this as "generates no code" because local variables are automatically zeroed on creation?
|
du00000001
Just Some Member
- Total Posts : 4071
- Reward points : 0
- Joined: 2016/05/03 13:52:42
- Location: Germany
- Status: offline
Re: "warning: (759) expression generates no code" WHY?
2020/11/28 11:02:06
(permalink)
AndersG He, he. Just popped in to complain about this.. Ie:
void foo(void) { int bar = 0; .. more code } I assume that it flags this as "generates no code" because local variables are automatically zeroed on creation?
I assume you don't use (read) bar in the snipped code. Local variables are NOT initialized automatically.
PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
|
Murton Pike Systems
Super Member
- Total Posts : 139
- Reward points : 0
- Joined: 2020/09/10 02:13:01
- Location: 0
- Status: offline
Re: "warning: (759) expression generates no code" WHY?
2020/11/28 14:15:53
(permalink)
if (ax==3); Another example of source code not generating any object code.
|
Hen
Super Member
- Total Posts : 122
- Reward points : 0
- Joined: 2018/10/24 04:01:44
- Location: 0
- Status: offline
Re: "warning: (759) expression generates no code" WHY?
2020/11/28 22:10:18
(permalink)
nigelwright7558 if (ax==3); Another example of source code not generating any object code.
Would that hold water even if: volatile int ax;
|
ric
Super Member
- Total Posts : 29435
- Reward points : 0
- Joined: 2003/11/07 12:41:26
- Location: Australia, Melbourne
- Status: online
Re: "warning: (759) expression generates no code" WHY?
2020/11/29 00:15:25
(permalink)
nigelwright7558 if (ax==3); Another example of source code not generating any object code. Impossible to comment without seeing the surrounding code.
To get a useful answer, always state which PIC you are using!
|
crosland
Super Member
- Total Posts : 2142
- Reward points : 0
- Joined: 2005/05/10 10:55:05
- Location: Warks, UK
- Status: offline
Re: "warning: (759) expression generates no code" WHY?
2020/11/29 03:17:16
(permalink)
nigelwright7558 if (ax==3); Another example of source code not generating any object code.
Another example of a completely pointless post devoid of any context.
|
AndersG
Super Member
- Total Posts : 241
- Reward points : 0
- Joined: 2008/08/05 04:51:24
- Location: 0
- Status: offline
Re: "warning: (759) expression generates no code" WHY?
2020/11/29 03:40:42
(permalink)
I assume you don't use (read) bar in the snipped code. Local variables are NOT initialized automatically.
My mistake, the variable(s) it complained about were actually global ones.
|
andersm
Super Member
- Total Posts : 2867
- Reward points : 0
- Joined: 2012/10/07 14:57:44
- Location: 0
- Status: online
Re: "warning: (759) expression generates no code" WHY?
2020/11/29 03:57:13
(permalink)
ric
nigelwright7558 if (ax==3); Another example of source code not generating any object code. Impossible to comment without seeing the surrounding code. It's an empty true-statement, so a NOP. if (ax == 3) { }
|
ric
Super Member
- Total Posts : 29435
- Reward points : 0
- Joined: 2003/11/07 12:41:26
- Location: Australia, Melbourne
- Status: online
Re: "warning: (759) expression generates no code" WHY?
2020/11/29 04:36:58
(permalink)
Good point. I missed the semi-colon, so didn't understand what he was getting at.
To get a useful answer, always state which PIC you are using!
|
Murton Pike Systems
Super Member
- Total Posts : 139
- Reward points : 0
- Joined: 2020/09/10 02:13:01
- Location: 0
- Status: offline
Re: "warning: (759) expression generates no code" WHY?
2020/11/29 08:21:53
(permalink)
andersm It's an empty true-statement, so a NOP.
if (ax == 3) { }
Compiler says "generates no code"
|
du00000001
Just Some Member
- Total Posts : 4071
- Reward points : 0
- Joined: 2016/05/03 13:52:42
- Location: Germany
- Status: offline
Re: "warning: (759) expression generates no code" WHY?
2020/11/29 09:16:30
(permalink)
nigelwright7558
andersm It's an empty true-statement, so a NOP.
if (ax == 3) { }
Compiler says "generates no code"
An empty statement is not a NOP but just "nothing". Now, why should the compiler genrate code for the comparison if just nothing is to be done in the true-branch. Keep in mind that this compiler is optimizing!
PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
|