<?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 Re: Ansi C compiler warning in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/ansi-c-compiler-warning/m-p/2710441#M721913</link>
    <description>This can actually be a warning that requires a coding change.  It came up in the course of a code migration that we're going through, and I wrote the following to the other people on the project:&lt;BR /&gt;&lt;BR /&gt;Apparently, the 11.0 compiler will treat some literals as variables of type const even if you don't explicitly declare them as such, but it will do so in a way that takes effect at execution time only: rather than terminating the compilation, the compiler simply issues a warning&lt;BR /&gt;&lt;BR /&gt;By default 'const' qualified objects are now stored in literal space using 474.  This may lead to run-time errors if the semantics of 'const' are violated&lt;BR /&gt;&lt;BR /&gt;and then when "the semantics of 'const' are violated" you get a bus error.  Not a core dump, just a bus error.  (To make the warning even more helpful, it doesn't always appear, and when it does there's no line number associated with it.).&lt;BR /&gt;&lt;BR /&gt;The only good thing about the problem is that it only seems to arise with code of a sort that I hope doesn't get written very much.  For example:&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;main(int argc, char *argv[])&lt;BR /&gt;{&lt;BR /&gt;void   OverlayLiteral(char *);&lt;BR /&gt;OverlayLiteral("ORIGINALSTRING");&lt;BR /&gt;return(EXIT_SUCCESS);&lt;BR /&gt;}&lt;BR /&gt;void   OverlayLiteral(char * arg)&lt;BR /&gt;{&lt;BR /&gt;sprintf(arg,"%s","NEWSTRING");&lt;BR /&gt;printf("arg is %s\n",arg);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;On 11.0, the sprintf marked in red will trigger a bus error, even though it will execute without any problem on 10.2 and fall through to print "arg is NEWSTRING".  Apparently, 11.0 saves "ORIGINALSTRING" in some kind of protected location.&lt;BR /&gt;&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;</description>
    <pubDate>Tue, 04 Jun 2002 20:08:04 GMT</pubDate>
    <dc:creator>Rich Homa</dc:creator>
    <dc:date>2002-06-04T20:08:04Z</dc:date>
    <item>
      <title>Ansi C compiler warning</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ansi-c-compiler-warning/m-p/2710439#M721911</link>
      <description>I'm using the Ansi C compiler to build my programs.  There is a switch "+w1" which displays additional warnings.  This switch is very useful for ensuring prototypes have been used, etc...&lt;BR /&gt;However, using this switch with code that contains const always produces the following warning:&lt;BR /&gt;"cc: warning 474: By default 'const' qualified objects are now stored in literal space.  This may lead to run-time errors if the semantics of 'const' are violated.&lt;BR /&gt;Is this an indication of a problem in the code?  I don't think it is.  If not is there a way to suppress this warning?</description>
      <pubDate>Wed, 24 Apr 2002 18:55:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ansi-c-compiler-warning/m-p/2710439#M721911</guid>
      <dc:creator>Andrew Blainey</dc:creator>
      <dc:date>2002-04-24T18:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: Ansi C compiler warning</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ansi-c-compiler-warning/m-p/2710440#M721912</link>
      <description>Yes, you can add the +W 474 flag to suppress that warning. You can actually specify a comman separated list of suppressed warning numbers after the '+W' argument.&lt;BR /&gt;&lt;BR /&gt;That warning is telling you that make sure you treat const as const in all files that may contain the specified variable; i.e. don't do anything in another source file to change it's value.&lt;BR /&gt;</description>
      <pubDate>Wed, 24 Apr 2002 19:41:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ansi-c-compiler-warning/m-p/2710440#M721912</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-04-24T19:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: Ansi C compiler warning</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ansi-c-compiler-warning/m-p/2710441#M721913</link>
      <description>This can actually be a warning that requires a coding change.  It came up in the course of a code migration that we're going through, and I wrote the following to the other people on the project:&lt;BR /&gt;&lt;BR /&gt;Apparently, the 11.0 compiler will treat some literals as variables of type const even if you don't explicitly declare them as such, but it will do so in a way that takes effect at execution time only: rather than terminating the compilation, the compiler simply issues a warning&lt;BR /&gt;&lt;BR /&gt;By default 'const' qualified objects are now stored in literal space using 474.  This may lead to run-time errors if the semantics of 'const' are violated&lt;BR /&gt;&lt;BR /&gt;and then when "the semantics of 'const' are violated" you get a bus error.  Not a core dump, just a bus error.  (To make the warning even more helpful, it doesn't always appear, and when it does there's no line number associated with it.).&lt;BR /&gt;&lt;BR /&gt;The only good thing about the problem is that it only seems to arise with code of a sort that I hope doesn't get written very much.  For example:&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;main(int argc, char *argv[])&lt;BR /&gt;{&lt;BR /&gt;void   OverlayLiteral(char *);&lt;BR /&gt;OverlayLiteral("ORIGINALSTRING");&lt;BR /&gt;return(EXIT_SUCCESS);&lt;BR /&gt;}&lt;BR /&gt;void   OverlayLiteral(char * arg)&lt;BR /&gt;{&lt;BR /&gt;sprintf(arg,"%s","NEWSTRING");&lt;BR /&gt;printf("arg is %s\n",arg);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;On 11.0, the sprintf marked in red will trigger a bus error, even though it will execute without any problem on 10.2 and fall through to print "arg is NEWSTRING".  Apparently, 11.0 saves "ORIGINALSTRING" in some kind of protected location.&lt;BR /&gt;&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Tue, 04 Jun 2002 20:08:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ansi-c-compiler-warning/m-p/2710441#M721913</guid>
      <dc:creator>Rich Homa</dc:creator>
      <dc:date>2002-06-04T20:08:04Z</dc:date>
    </item>
  </channel>
</rss>

