<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic improper behaviour with -O option in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/improper-behaviour-with-o-option/m-p/2986303#M718372</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have a c  code something like this&lt;BR /&gt;&lt;BR /&gt;void RegisterFunc(&lt;BR /&gt; int (*cb)(char *)&lt;BR /&gt; void *client_data&lt;BR /&gt; )&lt;BR /&gt;{&lt;BR /&gt;   callBackList[i].cb = cb;&lt;BR /&gt;   callBackList[i].cdata = client_data;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;void InvokeCallback()&lt;BR /&gt;{&lt;BR /&gt;   callBackList[i].cb((char *)callBackList[i].cdata)&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;int my_func(char *name)&lt;BR /&gt;{&lt;BR /&gt;   if(strcmp(name, "TEST"))&lt;BR /&gt;      return -1;&lt;BR /&gt;&lt;BR /&gt;    /* do the processing */&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;void foo()&lt;BR /&gt;{&lt;BR /&gt;   RegisterFunc(my_func, "TEST");&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;The argument name coming to 'my_func' is NULL when I use -O option for cc. It works fine when I remove the optimisation option.&lt;BR /&gt;&lt;BR /&gt;Please suggest a way out&lt;BR /&gt;&lt;BR /&gt;TIA&lt;BR /&gt;satya</description>
    <pubDate>Mon, 02 Jun 2003 10:10:00 GMT</pubDate>
    <dc:creator>Satya_6</dc:creator>
    <dc:date>2003-06-02T10:10:00Z</dc:date>
    <item>
      <title>improper behaviour with -O option</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/improper-behaviour-with-o-option/m-p/2986303#M718372</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have a c  code something like this&lt;BR /&gt;&lt;BR /&gt;void RegisterFunc(&lt;BR /&gt; int (*cb)(char *)&lt;BR /&gt; void *client_data&lt;BR /&gt; )&lt;BR /&gt;{&lt;BR /&gt;   callBackList[i].cb = cb;&lt;BR /&gt;   callBackList[i].cdata = client_data;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;void InvokeCallback()&lt;BR /&gt;{&lt;BR /&gt;   callBackList[i].cb((char *)callBackList[i].cdata)&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;int my_func(char *name)&lt;BR /&gt;{&lt;BR /&gt;   if(strcmp(name, "TEST"))&lt;BR /&gt;      return -1;&lt;BR /&gt;&lt;BR /&gt;    /* do the processing */&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;void foo()&lt;BR /&gt;{&lt;BR /&gt;   RegisterFunc(my_func, "TEST");&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;The argument name coming to 'my_func' is NULL when I use -O option for cc. It works fine when I remove the optimisation option.&lt;BR /&gt;&lt;BR /&gt;Please suggest a way out&lt;BR /&gt;&lt;BR /&gt;TIA&lt;BR /&gt;satya</description>
      <pubDate>Mon, 02 Jun 2003 10:10:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/improper-behaviour-with-o-option/m-p/2986303#M718372</guid>
      <dc:creator>Satya_6</dc:creator>
      <dc:date>2003-06-02T10:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: improper behaviour with -O option</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/improper-behaviour-with-o-option/m-p/2986304#M718373</link>
      <description>If "callBackList[i].cb" is some generic function pointer type, then you should cast it before calling through it.&lt;BR /&gt;*((int (*)(char *)) callBackList[i].cb)((char *)callBackList[i].cdata)&lt;BR /&gt;&lt;BR /&gt;That will tell the compiler what the parameter list should look like.  Without that it may assume that the parameter to the call is a (32-bit) integer.  That would damage a 64-bit char *.&lt;BR /&gt;&lt;BR /&gt;If that isn't the problem then I would suggest creating a small test case.  If it fails you will have an example.  If it works then you will have a difference to ponder while looking at your original code.</description>
      <pubDate>Mon, 02 Jun 2003 14:42:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/improper-behaviour-with-o-option/m-p/2986304#M718373</guid>
      <dc:creator>Mike Stroyan</dc:creator>
      <dc:date>2003-06-02T14:42:26Z</dc:date>
    </item>
  </channel>
</rss>

