2

I have many warnings when I compile my project under Eclipse CDT Indigo and g++ (Debian 4.9.2-10) 4.9.2. From here, it may be explained by some Eclipse parser bugs, plus possibly some external library bugs.

I will upgrade Eclipse of course, but I cannot now.

I would like then to suppress these cumbersome warnings. I read the manual here, but still I don't see how to identify which options to set. I have unchecked the -Wall option in Eclipse, but nothing is changed. All Eclipse warnings are disabled now.

Here is a pastbin of my compile log.

Community
  • 1
  • 1
lalebarde
  • 1,684
  • 1
  • 21
  • 36
  • Use gcc from command line. Eclipse has turned the compiler output into an impenetrable mess. I cannot even find what it warns about. To me these messages look like fragments of gcc **errors**, not warnings. – n. m. could be an AI Dec 28 '16 at 16:45
  • 1) I get exactly the same from the command line, 2) there is no error keyword, 3) the object files are build and the executable linked – lalebarde Dec 28 '16 at 17:18
  • Then something inside `make` must be filtering out your compiler output. Try running a single `g++` command without using `make`. Note there's no `warning` keyword either. – n. m. could be an AI Dec 28 '16 at 17:29
  • I don't use make, directly g++ commands. Just search for g++ in the pastbin to get them. my_g++ is just a symbolic link to a specific g++ version. For the test here, it is linked simply to g++. – lalebarde Dec 28 '16 at 19:21
  • I see `make all`, this is a typical invocation of `make`. The posted log has messages from several different invocations of a program called "my_g++". I have not a slightest idea what it does. Please post output of a single manual run of g++ (not "my_g++") . – n. m. could be an AI Dec 28 '16 at 22:32
  • As already written above: `# ls -l /usr/local/bin/my_g++ lrwxrwxrwx 1 root staff 12 déc. 3 17:32 /usr/local/bin/my_g++ -> /usr/bin/g++` – lalebarde Dec 29 '16 at 07:49
  • You are right for the `make` used by Eclipse, but I did not use a make when I compile from the command line, and I get the same results than with Eclipse. – lalebarde Dec 29 '16 at 07:55
  • What you have posted doesn't look like normal g++ output. Important lines are missing. Every error message should contain the word "error" and every warning message should contain the word "warning". None are present in your output. Either your installation is broken in a manner unknown to science, or you are not posting the entire output of g++. Please post a [mcve]. – n. m. could be an AI Dec 29 '16 at 07:55
  • I'm sorry, I was wrong blaming everything but gcc. Turns out gcc itself eats parts of its output. – n. m. could be an AI Dec 29 '16 at 18:30

1 Answers1

1

It looks like something ate your actual warning lines. All gcc warnings have the word "warning" in at least one of the lines.

EDIT Some builds of gcc actually produce similar messages ("note" lines, "required from" lines, "instantiated from" lines... but no actual "error" or "warning" line). It looks like there's a bug in gcc. — end edit.

Out of all gcc warnings, I know of only one that is related to overloading and has "note" submessages that lists candidate functions. The warning reads

C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second

and it cannot be turned off. If you see such warning, your program is non-compliant and you should fix it.

Here's an example of such non-compliant code. with function signatures matching yours:

#include <string>

struct KeyWord
{
    KeyWord(const std::string&);
    operator std::string&() const;
};

struct A
{
    bool operator() (const std::string&, const std::string&) const;
    bool operator() (const KeyWord&, const KeyWord&);
};

int main ()
{
    A a;
    std::string s;
    const std::string r;
    a(s, r);
}

Making the second operator() const solves the problem.

n. m. could be an AI
  • 112,515
  • 14
  • 128
  • 243
  • alright for your answer "it cannot be turned off". For the rest, my MCVE is [here](http://stackoverflow.com/questions/41384434/how-to-solve-ambiguity-in-operator-overloading-embedded-inside-a-struct/41384469#41384469). I have tried your const solution, but without success. As it is not directly related to the initial question, I have opened a dedicated question for it. – lalebarde Dec 29 '16 at 17:29
  • Now I understands all of it. Thanks. – lalebarde Dec 29 '16 at 17:56