You are not logged in.

#1 2018-10-10 06:58:12

snack
Member
From: Italy
Registered: 2009-01-13
Posts: 713

Weird GCC warning message

Hi, I get an obscure warning in my code from gcc (8.2.1):

<built-in>: warning:   by ‘operator’ [-Woverloaded-virtual]

I searched it literally on Google and got no match"

No results found for "<built-in>: warning: by ‘operator’ [-Woverloaded-virtual]".

To  me, it looks a lot like a bugged message but I may be wrong. Any hints? Thanks.

Last edited by snack (2018-10-10 06:58:33)

Offline

#2 2018-10-10 12:49:27

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,010
Website

Re: Weird GCC warning message

Oooh, this looks fun! Let's see...

Please post the entire output from GCC (with [ code ] tags).

After a quick internet search, my guess is that you created a variable name (or SOMETHING) that overwrites something in another library or file. For example, maybe you created a variable called "blarg" when you are using code that already has a variable named "blarg". In this scenario, you could fix it by renaming your variable to "myBlarg".

Can you remove files and comment out code to pinpoint where the error is coming from? In other words, get your code in a state where you do NOT see the error, then see what you need to introduce to make the error occur. Then post that code.

You could try compiling with "clang" instead of "gcc". It might even be a drop in replacement compiler. Does "clang" give an error message with more information?

Do you have any non-ASCII characters in your code that are not being displayed in your terminal output, giving you half of an error message that is very confusing?

Offline

#3 2018-10-10 13:37:40

snack
Member
From: Italy
Registered: 2009-01-13
Posts: 713

Re: Weird GCC warning message

Hi drcouzelis, thanks for your answer. I get the error in various files; this is the output from compiling one of them (build configured with cmake):

cd /home/mori/software/develop/GGSSoftware/Debug-Root6/src/montecarlo/scoring && /usr/bin/c++  -DG4INTY_USE_QT -DG4UI_USE -DG4UI_USE_QT -DG4VERBOSE -DG4VIS_USE -DG4VIS_USE_OPENGL -DG4VIS_USE_OPENGLQT -DG4_STORE_TRAJECTORY -DGGSScoring_EXPORTS -I/home/mori/software/install/ROOT_6.14.02/include -I/usr/include/python2.7 -I/home/mori/software/develop/GGSSoftware/include -I/home/mori/software/develop/GGSSoftware/Debug-Root6/include -isystem /home/mori/software/install/GEANT4_10.04.p01/include/Geant4 -isystem /home/mori/software/install/XERCESC_3.1.2/include  -W -Wall -pedantic -Wno-non-virtual-dtor -Wno-long-long -Wwrite-strings -Wpointer-arith -Woverloaded-virtual -Wno-variadic-macros -Wshadow -pipe -DG4USE_STD11 -std=c++14  -pipe -m64 -fsigned-char -pthread -std=c++14 -DROOT6 -fdiagnostics-color=always -g -DG4FPE_DEBUG -fPIC   -o CMakeFiles/GGSScoring.dir/GGSIntHitSD.cpp.o -c /home/mori/software/develop/GGSSoftware/src/montecarlo/scoring/GGSIntHitSD.cpp
<built-in>: warning:   by ‘operator’ [-Woverloaded-virtual]
<built-in>: warning:   by ‘operator’ [-Woverloaded-virtual]
<built-in>: warning:   by ‘operator’ [-Woverloaded-virtual]
<built-in>: warning:   by ‘operator’ [-Woverloaded-virtual]
<built-in>: warning:   by ‘operator’ [-Woverloaded-virtual]
<built-in>: warning:   by ‘operator’ [-Woverloaded-virtual]
<built-in>: warning:   by ‘operator’ [-Woverloaded-virtual]
<built-in>: warning:   by ‘operator’ [-Woverloaded-virtual]
<built-in>: warning:   by ‘operator’ [-Woverloaded-virtual]
<built-in>: warning:   by ‘operator’ [-Woverloaded-virtual]
<built-in>: warning:   by ‘operator’ [-Woverloaded-virtual]

About your other proposals:

- I don't understand your point about the overwritten variable. If I create blarg, and blarg already exists in that context, then I should get an error, not a warning

- I found that the warning comes from an included header. From here it's quite difficult to go on since that header is not mine but of I library I'm using, and it includes a lot of other headers. I might go deeper and begin to comment out code in that header, but in this moment it seems too much time consuming for my current availability. I will try later.

- replacing c++ with clang++ in the above posted compiler invocation I get no warning at all. As an interesting addition, I have also gcc 5.5.0 in my system (from gcc5 aur package), and compiling with gcc-5 gives no warning as well.

- I don't know about non-ASCII characters. As reported above, the error comes from an included header so it's not in my code, and I do not have the time to go through it now.

Offline

#4 2018-10-10 23:08:59

hpmachining
Member
From: Michigan
Registered: 2016-11-23
Posts: 19
Website

Re: Weird GCC warning message

This is what the GCC manual says about the  -Woverloaded-virtual option.

Warn when a function declaration hides virtual functions from a base class. For example, in:

struct A {
  virtual void f();
};

struct B: public A {
  void f(int);
};

the A class version of f is hidden in B, and code like:

B* b;
b->f();

fails to compile.

So it appears that somewhere a derived class is overriding a virtual method from the base class with a method with a different signature, or the base class has overloaded the virtual method and not all same named methods are overridden in the derived class, resulting in the same named methods with different signatures in the base class being hidden from instances of the derived class.

I don't understand why you don't get the warning in older g++ or clang++ if you invoked with the same options. I suppose that makes it possible that there is a bug in the latest GCC giving a false positive. You would need to examine the offending code to determine this.

Offline

#5 2018-12-10 10:10:54

alexneu
Member
Registered: 2018-12-10
Posts: 2

Re: Weird GCC warning message

hpmachining wrote:

This is what the GCC manual says

this stuff wont even compile. wtf

Offline

#6 2018-12-10 15:30:25

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 16,275

Re: Weird GCC warning message

alexneu wrote:
hpmachining wrote:

This is what the GCC manual says

this stuff wont even compile. wtf

Not quite what we are supposed to do with that.  Are you having the same issue with overloaded virtual functions? 
If so, please provide an example of "stuff"

If not, please start a new thread, so as not to hijack this one. But again, include an example of stuff and explicit error messages.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#7 2018-12-10 21:04:33

alexneu
Member
Registered: 2018-12-10
Posts: 2

Re: Weird GCC warning message

struct A {
  virtual void f();
};

man you should know that it wont be compiled. We have broken code in docs(?).
wont be linked ,particularly
this f()  must be defined ,overrides wont help there



about problem in first post:
this stuff

using

Last edited by alexneu (2018-12-10 22:28:30)

Offline

Board footer

Powered by FluxBB