Skip to content

Conversation

@vandenman
Copy link
Collaborator

To test, save the code below in src/russian_roulette.cpp

#include <RcppArmadillo.h>

// [[Rcpp::export]]
double bigbomb(const arma::mat& v, const int i) {
  return v(i);
}

and build. Note that with this PR, you should see -DARMA_NO_DEBUG in the build panel of RStudio. Next, in R do

v <- t(c(1, 2, 3))
bgms:::bigbomb(v, 10000000)

and then RStudio will show the notorious bomb before restarting.

To revert, open Makevars.in and change

-PKG_CPPFLAGS = @RCPP_PARALLEL_CPPFLAGS@ -DARMA_NO_DEBUG
+PKG_CPPFLAGS = @RCPP_PARALLEL_CPPFLAGS@ #-DARMA_NO_DEBUG

build once more, and then the R code shows:

> bgms:::bigbomb(v, 10000000)
Error: Mat::operator(): index out of bounds

@MaartenMarsman MaartenMarsman merged commit 769e8c1 into Bayesian-Graphical-Modelling-Lab:main Oct 3, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants