Skip to content

Commit

Permalink
Avoid a few new warnings
Browse files Browse the repository at this point in the history
Hopefully, they're false positives.  Tests run correctly.
  • Loading branch information
lballabio committed Sep 27, 2023
1 parent d08dc85 commit a2e4bc5
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Examples/BermudanSwaption/BermudanSwaption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ int main(int, char* []) {
Size j = numCols - i -1; // 1x5, 2x4, 3x3, 4x2, 5x1
Size k = i*numCols + j;
auto vol = ext::make_shared<SimpleQuote>(swaptionVols[k]);

#if defined(__GNUC__) && (__GNUC__ >= 12)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif

swaptions.push_back(ext::make_shared<SwaptionHelper>(
swaptionMaturities[i],
Period(swapLengths[j], Years),
Expand All @@ -180,6 +186,11 @@ int main(int, char* []) {
indexSixMonths->dayCounter(),
indexSixMonths->dayCounter(),
rhTermStructure));

#if defined(__GNUC__) && (__GNUC__ >= 12)
#pragma GCC diagnostic pop
#endif

swaptions.back()->addTimesTo(times);
}

Expand Down
9 changes: 9 additions & 0 deletions ql/models/shortrate/calibrationhelpers/swaptionhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,17 @@ namespace QuantLib {

ext::shared_ptr<Exercise> exercise(new EuropeanExercise(exerciseDate));

#if defined(__GNUC__) && (__GNUC__ >= 12)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif

swaption_ = ext::make_shared<Swaption>(swap_, exercise);

#if defined(__GNUC__) && (__GNUC__ >= 12)
#pragma GCC diagnostic pop
#endif

BlackCalibrationHelper::performCalculations();

}
Expand Down
21 changes: 21 additions & 0 deletions test-suite/bermudanswaption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,19 @@ void BermudanSwaptionTest::testCachedG2Values() {
for (const auto& i : swap->fixedLeg()) {
exerciseDates.push_back(ext::dynamic_pointer_cast<Coupon>(i)->accrualStartDate());
}

#if defined(__GNUC__) && (__GNUC__ >= 12)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif

swaptions.push_back(ext::make_shared<Swaption>(swap,
ext::make_shared<BermudanExercise>(exerciseDates)));

#if defined(__GNUC__) && (__GNUC__ >= 12)
#pragma GCC diagnostic pop
#endif

}

const Real a=0.1, sigma=0.01, b=0.2, eta=0.013, rho=-0.5;
Expand Down Expand Up @@ -343,8 +354,18 @@ void BermudanSwaptionTest::testTreeEngineTimeSnapping() {

auto callDate = initialCallDate + i * Days;
if (calendar.isBusinessDay(callDate)) {

#if defined(__GNUC__) && (__GNUC__ >= 12)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif

auto bermudanSwaption = makeBermudanSwaption(callDate);

#if defined(__GNUC__) && (__GNUC__ >= 12)
#pragma GCC diagnostic pop
#endif

auto model = ext::make_shared<HullWhite>(termStructure);

bermudanSwaption->setPricingEngine(ext::make_shared<FdHullWhiteSwaptionEngine>(model));
Expand Down

0 comments on commit a2e4bc5

Please sign in to comment.