Can't set bin content for certain TH1 default buffer sizes

Dear ROOT experts,

I’m trying to set the bin content in a TH2F histogram, which was built via dynamic binning.
It seems that this does work only for certain values of the TH1 default buffer size (TH1::GetDefaultBufferSize()).
Now I am not sure if this is a bug or not.

To be more concrete, here is a simple example which shows the problem (using ROOT 5.32.00):

{
   const Int_t numberOfPoints = 10000;
   TH1::SetDefaultBufferSize(numberOfPoints); // does not work
   // TH1::SetDefaultBufferSize(numberOfPoints - 1); // this works!
   TH2F* hist = new TH2F("hist", "", 50, 1, -1, 50, 1, -1);

   TRandom* rand = new TRandom();
   for (int i = 0; i < numberOfPoints; ++i) {
      Float_t x = rand->Gaus();
      Float_t y = rand->Gaus();
      hist->Fill(x, y);
   }
   hist->BufferEmpty();

   for (Int_t i = 1; i <= hist->GetNbinsX(); ++i) {
      for (Int_t k = 1; k <= hist->GetNbinsY(); ++k) {
         hist->SetBinContent(i, k, 1);
      }
   }

   hist->Draw("COLZ");
}

In this example I create and fill a TH2F histogram. After calling hist->BufferEmpty(); I set the bin content of all bins to 1.

When executing this script you’ll see that the histogram shows a 2D gaussian, i.e. the bin content was not set correctly!
But if I decrease the TH1 default buffer size by 1 via TH1::SetDefaultBufferSize(numberOfPoints - 1); (see the commented line in the example), the bin content is set correctly to 1.

Why is this happening?
Is there a way to make the SetBinContent() function work correctly for arbitrary values of the TH1 default buffer size?

Kind regards,
Alexander Voigt

[code]{
const Int_t numberOfPoints = 10000;
TH1::SetDefaultBufferSize(numberOfPoints + 1);
// TH1::SetDefaultBufferSize(numberOfPoints - 1);
TH2F* hist = new TH2F(“hist”, “”, 50, 1, -1, 50, 1, -1);

// “TRandom3” (i.e. “gRandom” by default) is much better than “TRandom”
// see: http://root.cern.ch/root/html/TRandom.html
// http://root.cern.ch/root/html/TRandom3.html
for (int i = 0; i < numberOfPoints; ++i) {
Float_t x = gRandom->Gaus();
Float_t y = gRandom->Gaus();
hist->Fill(x, y);
}
// see: http://root.cern.ch/root/html/TH1.html#TH1:BufferEmpty
// http://root.cern.ch/root/html/TH2.html#TH2:BufferEmpty
hist->BufferEmpty(1);

for (Int_t i = 1; i <= hist->GetNbinsX(); ++i) {
for (Int_t k = 1; k <= hist->GetNbinsY(); ++k) {
hist->SetBinContent(i, k, 1);
}
}

hist->Draw(“COLZ”);
}[/code]