[Bug c++/15098] New: Explicit keyword forbids passing of temporary objects

bartosch at or dot uni-bonn dot de gcc-bugzilla@gcc.gnu.org
Fri Apr 23 11:35:00 GMT 2004


The following code does not compile with 3.4.0: 
 
class EXP { 
public: 
   EXP() {} 
   explicit EXP( EXP const & other)  {} 
}; 
 
void f(EXP const & o) {} 
 
int main() { 
   EXP p1; 
   f(p1); 
   f(EXP()); 
} 
 
It used to compile with 3.3.x and still compiles with icc 8.x, Comeau 4.3.x, 
xlC 6.x.  
 
The error is:  
 
expli.C:12: error: no matching function for call to `EXP::EXP(const EXP&)' 
 
I do not see the need to call EXP::EXP(const EXP&) in line 12: 
 
   f(EXP()); 
 
A temporary is created and is passed by reference to f(). 
 
I could not find any hint that the new gcc behaviour is more standard 
compliant than the old one.

-- 
           Summary: Explicit keyword forbids passing of temporary objects
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bartosch at or dot uni-bonn dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15098



More information about the Gcc-bugs mailing list