
496 P.2d 197 (1972)
W.J. SEUFERT LAND CO., an Oregon Corporation, Respondent,
v.
Ralph W. GREENFIELD and Wilma T. Greenfield, Husband and Wife, Appellants.
Supreme Court of Oregon, In Banc.
Argued and Submitted April 6, 1972.
Decided April 26, 1972.
*198 R.W. PicKell, Salem, argued the cause and filed briefs for appellants.
Edward L. Clark, Jr., Salem, argued the cause for respondent. On the brief were Clark & Marsh, Norma Paulus, Salem, and Dick & Dick, The Dalles.
TONGUE, Justice.
This is an action upon a guaranty agreement under which defendants guaranteed payments of rent due under the lease of a building owned by plaintiff in The Dalles and leased for use as a restaurant to a corporation which became insolvent.
Defendants' answer alleged, as an affirmative defense, that plaintiff entered into an agreement with the trustee in bankruptcy under which plaintiff "settled and abandoned any and all claims on account of rental incurred" by the lessee, with the effect of releasing the obligation of defendants as obligors.[1] Plaintiff's reply denied these allegations and also alleged that the guaranty agreement included a provision under which defendants, as guarantors, agreed that they would "assert no defense whatever to any action * * * to enforce this guarantee * * * except the defense of the payment of rental at the times and in the manner specified" in the lease agreement.[2]
After trial before a jury plaintiff moved for a directed verdict, which was granted.[3] Defendants appeal.
Defendants contend on this appeal (1) that because the guaranty agreement included a provision under which all defenses (except payment) were waived in advance, that agreement was against public policy and void, and (2) that the agreement by plaintiff with the "bankruptcy court" was, in effect, a compromise settlement with the principal debtor, with the approval of the bankruptcy court, and therefore released the obligation of defendants as guarantors, thus constituting a valid defense, contrary to the holding of the trial court.[4]
Plaintiff responds by contending (1) that defendants failed to raise in the trial court the issue of the illegality of the guaranty agreement; and that the contract provision for waiver of defenses was not invalid, but in any event, did not invalidate the entire guaranty agreement so as to prevent its enforcement; and (2) that the order of the bankruptcy court, which confirmed the surrender of the premises to plaintiff and the sale of the restaurant equipment back to plaintiff, was not an abandonment of plaintiff's claim against the lessee for unpaid rent and did not discharge defendants' obligation as guarantors.
*199 For the purposes of this decision we shall assume, without deciding, that defendants were not foreclosed from raising on appeal, for the first time, the question of the illegality of the guaranty agreement because of its provision under which defendants agreed to waive all defenses to enforcement of the guaranty agreement other than payment of the rent.[5]
We have previously held some contracts to be void in their entirety as against public policy.[6] Where, however, the entire contract is not contrary to public policy, but includes a separable provision which is invalid as contrary to public policy, we have enforced the remaining provisions of such a contract.[7] In our opinion, the provision of this guaranty agreement waiving defenses, if invalid, is a separable provision and does not invalidate the remaining provisions of this guaranty agreement.
Coming to the more specific question of the validity of contract provisions waiving defenses, we have not previously had occasion to consider contract provisions under which all defenses would be waived. Neither has our attention been called to any previous case in which we have held to be invalid contract provisions to waive any particular defenses, except to the extent that such provisions may be invalid because of the terms of a particular statute.[8]
We have indicated, however, that agreements waiving some defenses may be valid and not contrary to public policy. Thus, we recently held that "choice of forums" provisions of a contract under which the parties agreed that any litigation under the contract could not be filed in the courts of Oregon, but only in the courts of Ohio, was a valid contract provision in the absence of a showing that its application *200 would be unfair or unreasonable. Reeves v. Chem Industrial Company, Or., 495 P.2d 729 (April 4, 1972).[9]
It has been said that a contract provision agreeing to waive all defenses is invalid.[10] The most obvious reason in support of such a position is that such a contract provision, by its terms, would not only bar defenses which may be the proper subject of such a contract, such as the agreements relating to procedural remedies or rules of evidence,[11] but would also bar defenses which cannot properly be contracted away, such as the defense of fraud or usury.[12]
In our opinion, the more rational position is that a contract provision under which one party agrees to waive all defenses is not per se invalid, and does not render the entire contract void, but that such a contract provision is only invalid when urged as a bar against a defense which may not be legally contracted away, while not invalid as a bar against a defense which may legally be the subject of such an agreement.[13]
Thus, it becomes necessary to determine whether a provision in a guaranty agreement under which the guarantor agrees to waive all defenses, except the defense of payment by the principal debtor, is a bar against the defense that an agreement between the lessor-creditor and the receiver in bankruptcy of the lessee-debtor to surrender possession of the leased premises and to abandon claims against the trustee in bankruptcy for rental payments accruing during the period of the bankruptcy estate, thereby releasing the obligation of defendants as guarantors, was a defense which could be subject to a legal and valid waiver agreement. This assumes, without deciding, that such an arrangement would otherwise constitute a compromise settlement between the creditor and debtor, so as to release the guarantor and thus constitute a defense, as contended by defendants. The answer to this question depends, in turn, upon whether an agreement to waive such a defense is contrary to public policy.[14]
We have previously declined to state any "hard and fast rule" for determining whether a contract is invalid as against public policy, but have held that each case must be determined in the light of its own facts and that "* * * the test is the evil tendency of the contract and not its actual injury to the public in a particular instance * * *." Pyle v. Kernan, 148 Or. 666, 673, 36 P.2d 580, 583 (1934). To the same general effect, 6A Corbin on Contracts 19, § 1375 (1951), quotes with approval from Bartron v. Codington County, 68 S.D. 309, 2 N.W.2d 337 (1942), as follows:
"That a policy reflected by the established trend of constitutional or statutory provisions, or of the decisions of the *201 courts, or of administrative practices, is public in character, is generally accepted. * * * After a broad review of the adjudications of the courts, we deem it unwise to attempt to limit the sources we may consult in determining whether a policy has become fixed in the community mind or conscience. Until firmly and solemnly convinced that an existent public policy is clearly revealed, a court is not warranted in applying the principle under consideration. It has been well said, `that the right of private contract is no small part of the liberty of the citizen, and that the usual and most important function of courts of justice is rather to maintain and enforce contracts than to enable parties thereto to escape from their obligation on the pretext of public policy unless it clearly appear that they contravene public right or the public welfare.' Baltimore & Ohio Southwestern Railway Co. v. Voigt, 176 U.S. 498, 20 S.Ct. 385, 387, 44 L.Ed. 560."
We can presently perceive no "evil tendency" which "clearly appear(s) [to] contravene the public right or public welfare" to be the result of such a settlement agreement, at least when applied in normal circumstances and, in particular, as applied to facts such as those involved in this case.
Defendants say that what they contend to be the compromise settlement in this case would preclude them from their right of subrogation against the principal debtor. It is not at all clear that such would be the effect of the order of the bankruptcy court in this case. Defendants also say that at the time of the order by the bankruptcy court confirming this arrangement there were sufficient funds to pay all or a large part of plaintiff's claim for rental payments due during the period of the bankruptcy proceedings if such claim had been considered to be an administrative expense. At that time, however, the trustee in bankruptcy and his attorney apparently denied that this claim was an administrative expense, placing plaintiff in the position of litigating that issue for some further period, during which the return of possession of the leased premises would still be withheld, without rent.
In any event, we do not believe that it is contrary to public policy for a creditor and a guarantor to enter into an agreement which may have the effect of limiting or destroying a right of subrogation under these circumstances. Moreover, the fact that the effect of a contract provision waiving such a defense may be harsh as applied to one of the contracting parties does not mean that the agreement is, for that reason alone, contrary to public policy.[15] This is particularly true where, as in this case, the contract in question was freely entered into between parties in equal bargaining positions and did not involve a contract of adhesion, such as some retail installment contracts and insurance policies.
Accordingly, we hold that the agreement between plaintiff and defendants under which defendants, as guarantors, agreed to waive all defenses to payment of the principal obligation other than actual payment was a valid agreement as against the defense in this case that the agreement by plaintiff "with the bankruptcy court" was a compromise agreement with the debtor which released the obligation of the defendants as guarantors.
It has been suggested that this court cannot properly hold that the "waiver of defense" clause is valid as a bar against the defense of compromise settlement because plaintiff has not made that specific contention in this court, but instead has contended primarily that there was no compromise settlement so as to discharge the guarantor. Upon examination of the record *202 however, we find that plaintiff never expressly waived or abandoned the right to rely upon the "waiver of defense" clause, after specifically alleging its provisions in plaintiff's reply. On the other hand, defendants have urged that this court consider their present contention that the "waiver of defense" clause was not only illegal, but rendered the entire guaranty agreement invalid, despite the fact that defendants made no such contention in the trial court.
In this posture of the case, we believe that it is proper for this court to determine the rights of the parties based upon the contentions made by them in their pleadings, including the allegations of plaintiff's reply specifically alleging that the guaranty agreement between the parties included the "waiver of defense" clause, which was then quoted in full, and also including defendants' present contention that the legality of that contract clause need not have been pleaded or raised in the trial court, but can be raised at any time.
We also believe that in determining the rights of the parties we may properly consider all of the provisions of the guaranty agreement, including the "waiver of defense" clause, whatever its legal effect may be as applied to the facts of this case and regardless of whether we find that its legal effect is, or is not, the same as that contended by either party, since both parties have been heard on this question and have cited numerous cases and authorities in their briefs in support of their respective contentions as to the validity and legal effect of that contract clause.
Because of our decision that the "waiver of defense" clause in this guaranty agreement precluded plaintiff's defense of compromise settlement, it is not necessary to decide whether, in the absence of that contract provision, the arrangements or agreement in this case and their confirmation by order of the bankruptcy court did not constitute a defense, as held by the trial court.[16]
It also follows that it is not necessary to decide whether, as contended by defendants in their reply brief, the making of such an arrangement without notice to or consent of defendants would constitute a defense.[17]
For all of these reasons, the judgment of the trial court must be affirmed.
NOTES
[1]  Defendants' answer also alleged as an affirmative defense that the lessee tendered payment of the balance due as rent, as well as an offset in the sum of $900.
[2]  That contract provision was as follows:

"Guarantors declare and covenant that guarantors will assert no defense whatever to any action, suit or proceeding at law that may be instituted to enforce this guarantee and the guarantors waive any defense of lessee arising for any reason, including the cessation of liability of lessee from any cause whatever, except the defense of payment of rental at the times and in the manner specified in the foregoing lease agreement."
[3]  The trial court held that defendants had not sustained its burden to establish the defense and offset referred to in note 1 and also held that the order of the bankruptcy court confirming the arrangement claimed by defendants to constitute a voluntary settlement did not discharge defendants' obligation as guarantors.
[4]  Defendants also contend on appeal that the trial court erred in holding that there was not a valid and good faith tender of rental payments so as to release the defendants as guarantors. As stated in note 3, the trial court held that defendants had not sustained the burden to prove that defense. After examining the record, we agree.
[5]  We have previously held that a defendant need not plead the illegality of a contract as an affirmative defense, but may raise that defense at any stage of the proceedings, if such illegality appears from plaintiff's own pleading as proof. Giddings et al. v. Giddings et al., 167 Or. 504, 514, 114 P.2d 1009, 119 P.2d 280 (1941). See also Jones v. Kubalek, 215 Or. 320, 328-329, 334 P.2d 490 (1959); and Intl. L. and W. Union v. Harvey Al. et al., 226 Or. 94, 97-98, 359 P.2d 112 (1961).
[6]  See Reiling v. Reiling, 256 Or. 448, 474 P.2d 327 (1970) (antenuptial agreement to forego payment of alimony); Traver v. Naylor et al, 126 Or. 193, 207, 268 P. 75 (1928) (agreement for which future cohabitation was part of the consideration); Vnuk v. Patterson, 118 Or. 602, 606-607, 247 P. 766 (1926) (promise to marry by a person then married to another person); Boyd et al v. Boyd et al. 112 Or. 658, 662, 230 P. 541 (1924) (agreement by the guardian of an incompetent and minor ward to convey property owned jointly by the guardian and ward, where not authorized by court). See also Rosenkrantz et al v. Barde, 107 Or. 338, 214 P. 893 (1923) (agreement for collusive bidding); School Dist. No. 1, etc. v. Teachers' Retirement Fund, 163 Or. 103, 110, 95 P.2d 720 (1939) (agreement to waive disability claim as condition of annuity); and Lane v. Brotherhood of L.E. & F., 157 Or. 667, 679, 73 P.2d 1396 (1937) (insurance contract provision making decisions by officers of fraternal benefit society final). In addition, see Restatement of the Law of Contracts 982ff, § 512 et seq.
[7]  See Stretch v. Murphy, 166 Or. 439, 448 112 P.2d 1018 (1941) (contract with provision investing courts with jurisdiction); State ex rel. Kahn v. Tazwell, 125 Or. 528, 543-545, 266 P. 238 (1928) (contract with provision limiting jurisdiction of courts); Oregon Growers' Etc. Assn. v. Lentz, 107 Or. 561, 574-575, 212 P. 811 (1923) (contract with provision limiting jurisdiction of courts). See also Rose v. Etling, 255 Or. 395, 467 P.2d 663 (1970) (agreement with provision to waive venue statute); and Nye v. Chase Nat. Bank, 34 F.2d 435 (8th Cir.1929) (guaranty contract with invalid provision).
[8]  Thus, in Rose v. Etling, 255 Or. 395, 467 P.2d 663 (1970), we held that a provision in a retail installment contract under which the purchaser agreed, in effect, to waive the defense of venue and to consent to venue in Multnomah County in the event of any action by the seller, regardless of the county of residence of the purchaser, was invalid because of the terms of ORS 83.160, as adopted in 1963 to protect purchasers under retail installment contracts.
[9]  In so holding, this court limited, if not overruled, its former decision in State ex rel. Kahn v. Tazwell, 125 Or. 528, 543, 266 P. 238 (1928).
[10]  See 6 Williston on Contracts 4863, § 1722 (rev. ed 1938), and comment, 39 Yale L.J. 727 (1930).
[11]  See 6 Williston, supra note 10, 4862, 4864, §§ 1722, 1723.
[12]  See Annot., 44 A.L.R.2d 8 (1955), at 169, and 39 Yale L.J., supra note 10, at 729.
[13]  39 Yale L.J., supra note 10, at 734. Cf. Anglo-California Trust Co. v. Hall, 61 Utah 223, 211 P. 991, 993 (1922). holding that a contract provision under which the purchaser under a conditional sales contract agreed that in the event of assignment by the seller the purchaser should be precluded from attacking the validity of the agreement on any ground, while not precluding the defense of fraud, would preclude the defense of breach of warranty. To the same effect, see John Deere Company of Moline v. Behling. 26 Utah 2d 30, 484 P.2d 170, 172 (1971). See also Reisler v. Dempsey, Sup., 173 N.Y.S. 212, 213 (1918); and 44 A.L.R.2d, supra note 12, at 162. But see American Nat. Bank of San Francisco v. A.G. Sommerville, Inc., 191 Cal. 364, 216 P. 376 (1923); and Pacific Acceptance Corporation v. Whalan, 43 Idaho 15, 248 P. 444 (1926).
[14]  See cases cited supra note 6.
[15]  Minneapolis Threshing Mach. Co. v. Hocking, 54 N.D. 559, 209 N.W. 996 (1926). To the same effect, see City of Reedsport v. Hubbard et ux., 202 Or. 370, 385, 274 P.2d 248 (1954); Bliss v. Southern Pacific Co. et al, 212 Or. 634, 646, 321 P.2d 324 (1958); and 6A Corbin on Contracts 19, § 1375 (1951).
[16]  But see Jackson v. First National Bank of Greeley, 28 Colo. App. 415, 474 P.2d 640 (1970), and Lutz v. Frick Company, 242 Ind. 599, 181 N.E.2d 14, 17 (1962).
[17]  In support of that contention defendants cite Marshall-Wells Co. v. Tenney et al., 118 Or. 373, 393, 244 P. 84 (1926), and Ebco, Inc. v. Bechtold, 251 Or. 543, 547, 446 P.2d 120 (1968).
