<div dir="ltr"><div><div>I am no C expert but looking at the code I think...<br><br>s = <span style="background-color:rgb(255,255,0)">(s - out.s)</span> + func (&out); <br><br>The yellow highlight is where your p<font>arentheses are used 
                to group sub-expressions to force a different precedence which is correct but...<br><br></font><font>s =<span style="background-color:rgb(255,242,204)"> (s - out.s<span style></span>)</span> +<span style="background-color:rgb(106,168,79)"> func (&out);</span><br>
<br></font></div><font>The green highlight <b>IS</b> a function declaration and according to C operator precedence will be evaluated by gcc first ?<br></font></div><div><font>This may help : <a href="http://www.difranco.net/compsci/C_Operator_Precedence_Table.htm">http://www.difranco.net/compsci/C_Operator_Precedence_Table.htm</a> ( See note 1 as well please )<br>
</font></div><div><font><br></font></div><font>Step it through gdb and you will see what I mean :-)<br></font><div><font><br></font></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Oct 30, 2013 at 11:50 PM, William Park <span dir="ltr"><<a href="mailto:opengeometry-FFYn/CNdgSA@public.gmane.org" target="_blank">opengeometry-FFYn/CNdgSA@public.gmane.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Question for C expert...  Given the following<br>
<br>
    char *s;<br>
    struct { char *s; } out;<br>
    char *func();<br>
<br>
    s = (s - out.s) + func (&out);<br>
<br>
where 'out' is changed inside function 'func'.  What I want is<br>
    - to calculate (s - out.s) first, then<br>
    - add that difference to pointer returning from func().<br>
Here, order is important, because func() changes 'out'.<br>
<br>
However, gcc is doing<br>
    s = func (&out) + (s - out.s);<br>
<br>
Is pointer arithmetic always done as<br>
    (pointer) + (int)<br>
even if I write<br>
    (int) + (pointer)<br>
?<br>
<br>
PS.  Of course, using intermediate variable solves the problem.  But, my<br>
understanding is that '+' is left-to-right precedence.<br>
<span class="HOEnZb"><font color="#888888">--<br>
William<br>
--<br>
The Toronto Linux Users Group.      Meetings: <a href="http://gtalug.org/" target="_blank">http://gtalug.org/</a><br>
TLUG requests: Linux topics, No HTML, wrap text below 80 columns<br>
How to UNSUBSCRIBE: <a href="http://gtalug.org/wiki/Mailing_lists" target="_blank">http://gtalug.org/wiki/Mailing_lists</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><span style="font-family:comic sans ms,sans-serif"><b>Aruna Hewapathirane</b><br>Consultant/Trainer<br>Phone : 647-709-9269<br>Website:<a href="http://goog_1768911931" target="_blank"> </a><a href="http://sahanaya.net/aruna/" target="_blank">Open Source Solutions</a></span><br>
<br><br><a href="https://sites.google.com/site/arunahewapathirane/home/business-card/buisness-card.png?attredirects=0" target="_blank"><br></a>
</div>