Indian Penal Code (IPC)
Section 88. Act not intended to cause death, done by consent in good faith for person’s benefit.
Nothing which is not intended to cause death, is an offence by reason of any harm which it may cause, or be intended by the doer to cause, or be known by the doer to be likely to cause, to any person for whose benefit it is done in good faith, and who has given a consent, whether express or implied, to suffer that harm, or to take the risk of that harm
A, a surgeon, knowing that a particular operation is likely to cause the death of Z, who suffers under a painful complaint, but not intending to cause Z’s death, and intending in good faith, Z’s benefit performs that operation on Z, with Z’s consent. A has committed no offence.
Consent is good defence to all offences in general. But if once it is proved in a case of rape that the girl in question was below 16 years, her consent becomes wholly irrelevant and the accused is liable for the offence as if no consent were obtained; Harpal Singh v. State of Himachal Pradesh, AIR 1981 SC 361.