Re: Cleanup for cryptographic algorithms vs. compiler optimizations



Bernd Walter <ticso@xxxxxxxxxxxxxxxxx> writes:
I'm not sure when removing a memset is allowed.

Always, if the compiler can determine that the data will not be used
later.

In more general terms, the compiler is allowed to make any changes it
likes to the program as long as the end result behaves exactly like it
would if it hadn't been changed. This is called the "as if" rule. For
instance, if you call printf() or fprintf() with a format string that
does not contain any conversion specifiers, gcc will call gets() or
fgets() instead.

Maybe passing volatile pointers might be enough.

You can't pass a volatile pointer to memset.

DES
--
Dag-Erling Smørgrav - des@xxxxxx
_______________________________________________
freebsd-current@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: Test whether `line in `READ (unit, "(A)") line was big enough
    ... In C, it is done with fgets(), (assuming you don't read a character ... the '\n' record terminator, or as much as fits in the buffer, followed ... It's compiler specific => not portable ... As others have said, non-advancing I/O, which was at least in part ...
    (comp.lang.fortran)
  • Re: lang/perl5.10 broken
    ... Bernd Walter writes: ... Silly question: do you have enough swap space enabled? ... 10M is used during compiler runs and the second was with 1G on external ... I also saw no kernel message that the system was out of space. ...
    (freebsd-current)
  • Re: lang/perl5.10 broken
    ... Bernd Walter writes: ... Silly question: do you have enough swap space enabled? ... 10M is used during compiler runs and the second was with 1G on external ... I also saw no kernel message that the system was out of space. ...
    (freebsd-current)
  • Re: gets() is dead
    ... It is possible, though unfortunately not easy, to write a compiler that handles buffer overflows on getscorrectly and safely, by terminating the program with an error message. ... If it was trivial to use fgets() safely then peole wouldn't have had such trouble creating correct code. ... If you tell it to overrun the buffer by one, it may return a number out by a factor of ten, but it will probably crash, we can write a compiler that guarantees it will crash, and it is almost certainly better that it crash than that it calculate the wrong value. ...
    (comp.lang.c)
  • Re: function
    ... it's fgets that adds the terminating null ... The compiler is not the only entity that adds null ... any such character is at the end of the line ...
    (comp.lang.c)