[tor-bugs] #4421 [Tor Client]: Some pure functions have impure code

Tor Bug Tracker & Wiki torproject-admin at torproject.org
Mon Nov 7 14:17:32 UTC 2011


#4421: Some pure functions have impure code
------------------------+---------------------------------------------------
 Reporter:  Sebastian   |          Owner:     
     Type:  defect      |         Status:  new
 Priority:  normal      |      Milestone:     
Component:  Tor Client  |        Version:     
 Keywords:              |         Parent:     
   Points:              |   Actualpoints:     
------------------------+---------------------------------------------------
 two examples I found while checking this out were
 smartlist_string_num_isin() which calls tor_snprintf(), which isn't
 defined as pure. And some other pure functions use tor_assert(), which
 does file IO. If I understand this correctly, pure functions shouldn't be
 allowed to call impure functions nor do IO.

 unfortunately, GCC only treats this as a hint to the optimizer, and
 doesn't check to see if it makes sense.

 Thanks to [4ZM] who brought up pure functions in #tor-dev :)

-- 
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/4421>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list