[EMAIL PROTECTED] wrote:
> >Nothing in ISO C standard disallows this.  ISO C explicitly states
> >that changing the value of a string literal is undefined behavior.
> >So placing them in read-only sections and folding them together is
> >undetectable in a conforming program.
> 
> I think he referred to the outcome of such a test:
> 
>         if ("false" == "false") ...
> 
> Would 1 be a conforming result?

Both "true" (=1) and "false" (=0) would be a "conforming result" for a
"string literal". But my comment/question was for non-"string literal"
data, e.g.
-- snip --
const float a_number = 10.-1;
const float b_number = 11.-2;
const float c_number = 12.-3;
const float d_number =    9.0;
-- snip --
... could be (optionally when a matching compiler/linker option is set)
folded into one physical location since they all have the same value.
The implementation in the compiler/linker would simply scan the
read-only data section of the application for a location with the
matching value (while makeing sure alignment etc. is Ok) and set the
address of the |const| variable to this location. However this needs to
be an option which is seperate from "-xstrconst" since this behaviour is
AFAIK not standard-conformant ("-xstrconst" itself is
standard-conformant).

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) [EMAIL PROTECTED]
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 7950090
 (;O/ \/ \O;)
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to