This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: c++/9315: [3.2/3.3/3.4 regression] problems with overload resolution


Old Synopsis: g++ doesn't create any code for this testcase
New Synopsis: [3.2/3.3/3.4 regression] problems with overload resolution

State-Changed-From-To: open->analyzed
State-Changed-By: reichelt
State-Changed-When: Thu Jan 16 01:55:45 2003
State-Changed-Why:
    Confirmed (sort of).
    
    First of all, the message I get is:
    
    testcase2.cxx: In function `int testcase()':
    testcase2.cxx:12: choosing `void operator+(const fix&, double)' over `operator+'
    testcase2.cxx:12:   because worst conversion for the former is better than 
       worst conversion for the latter
    
    That's not a warning, but an error message (a warning would have the word
    "warning" in front of the messages).
    And that's why no object file is generated.
    
    BTW, with gcc 3.3 you cannot confuse errors with warnings any more:
    
    testcase2.cxx: In function `int testcase()':
    testcase2.cxx:12: error: choosing `void operator+(const fix&, double)' over `
       operator+'
    testcase2.cxx:12: error:   because worst conversion for the former is better 
       than worst conversion for the latter
    
    Some questions, however remain:
    Why is that an error and not a warning? At least the wording is strange,
    since the compiler told the user what was done to resolve a problem. 
    If I specify "-pedantic" I get the following message, which is what I
    would expect from an error message (well, almost - the last two lines are
    redundant and could use some clean-up):
    
    testcase2.cxx: In function `int testcase()':
    testcase2.cxx:12: ambiguous overload for `fix& + float&' operator
    testcase2.cxx:12: candidates are: operator+(double, float) <built-in>
    testcase2.cxx:4:                 void operator+(const fix&, double)
    testcase2.cxx:4:                 void operator+(const fix&, double)
    
    In gcc 2.95.3 the situation is handled differently:
    Without "-pedantic" the code compiles (without warning).
    With "-pedantic" we get a similer error message (without the duplicate line):
    
    testcase2.cxx: In function `int testcase()':
    testcase2.cxx:12: ambiguous overload for `fix & + float &'
    testcase2.cxx:12: candidates are: operator +(double, float) <builtin>
    testcase2.cxx:4:                 void operator +(const fix &, double)
    
    To summarize, I would suggest the following:
    * Decide whether the code should compile without "-pedantic" or not.
      If yes, make the error a warning - if no, use the same error message
      as with "-pedantic".
    * Remove the duplicate line in the "-pedantic" error message.
    
    Since the situation is more confusing than in gcc 2.95.3 I rate this
    as a regression.
    
    Regards,
    Volker

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9315


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]