Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#4421 closed defect (fixed)

Some pure functions have impure code

Reported by: Sebastian Owned by:
Priority: High Milestone: Tor: 0.2.3.x-final
Component: Core Tor/Tor Version:
Severity: Keywords: easy tor-client
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:


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 :)

Child Tickets

Change History (5)

comment:1 Changed 9 years ago by nickm

Keywords: easy added
Milestone: Tor: 0.2.3.x-final
Priority: normalmajor

IMO we should just kill attribute pure ; I don't believe we actually use it in any context where it helps.

comment:2 Changed 9 years ago by Sebastian

Status: newneeds_review

Great, I'm happy to kill this, too. pure_removal in my repo has a branch for it

comment:3 Changed 9 years ago by nickm

Resolution: fixed
Status: needs_reviewclosed

Merged it into master; thanks!

comment:4 Changed 8 years ago by nickm

Keywords: tor-client added

comment:5 Changed 8 years ago by nickm

Component: Tor ClientTor
Note: See TracTickets for help on using tickets.