Error on TH1D draw: is signal a reserved word?

Hello,
I’m a bit confused… is this a BUG or the word “signal” is reserved?
Here is the very basic code I’m using:

{
  TFile *outFile = new TFile("test.root","RECREATE");
  TH1D *signal = new TH1D("signal","",1000,60,4000);
  signal->Fill(100);
  signal->Write();
  outFile->Close();
}

This macro run correctly but if I open the test.root file and I try to use

signal->Draw()

I get the following error:

ROOT_prompt_2:1:7: error: member reference base type 'void (*(int, void (*)(int)))(int)' is not a structure or union

But if I open the histogram from a TBrowser (with double clicking on the histo) no error and everything is ok. Moreover If I change the name (first argument of the constructor) of the histo “signal” to “signal0” when I book the TH1D everything is fine…

Other info: if I open root and I run this 2 very basic commands

TH1D *signal = new TH1D("signal","",1000,60,4000);
signal->Fill(100);

I get the following error:

ROOT_prompt_1:1:1: error: reference to 'signal' is ambiguous
signal->Fill(100);
^
ROOT_prompt_0:1:7: note: candidate found by name lookup is '__cling_N50::signal'
TH1D *signal = new TH1D("signal","",1000,60,4000);
      ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/csignal:52:9: note: candidate found by name lookup is 'std::__1::signal'
using ::signal _LIBCPP_USING_IF_EXISTS;
        ^

Finally I tested on a different platform: a standard CMS user interface (Linux ui02.recas.ba.infn.it 3.10.0-1160.71.1.el7.x86_64 #1 SMP Tue Jun 28 15:37:28 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux) and on LXPLUS and I get a similar error (when I book the histo or when I fill the histo).

So I guess this is something which we have to live with (but the word signal in HEP is used a lot… so… am I the first one to notice this problem???).

Best

Attilio


ROOT: Version: ROOT 6.26/06
Platform: macOS ventura 13.0.1
Compiler:


See std::signal - cppreference.com

Thanks… I didn’t think about c++.
Best

Attilio

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.