Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1441338

Summary: Explicit keyword does not prevent gcc 6.2 from compiling below code
Product: Red Hat Developer Toolset Reporter: Frank Hirtz <fhirtz>
Component: gccAssignee: Marek Polacek <mpolacek>
Status: CLOSED ERRATA QA Contact: Michael Petlan <mpetlan>
Severity: high Docs Contact:
Priority: unspecified    
Version: DTS 6.1 RHEL 6CC: jakub, jason, kanderso, law, mcermak, mnewsome, mpetlan
Target Milestone: alpha   
Target Release: 6.1   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: devtoolset-7-gcc-7.1.1-7.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-10-24 09:47:20 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Frank Hirtz 2017-04-11 17:18:31 UTC
Description of problem:

What problem/issue/behavior are you having trouble with?  What do you expect to see?

I am using dev toolset 6.0. Here is a small reproduction: 
//a.C
#include <string>
#include <iostream>

class Trouble {
  public:
    explicit Trouble(int) { std::cout << "int" << std::endl; }

    Trouble(const char *) { std::cout << "const char*" << std::endl; }
    // Trouble(const signed char *) {}
    Trouble(const unsigned char *) { std::cout << "const unsigned char* " << std::endl;}

  private:
    std::string data;
};

Trouble makeTroubleObject() { return Trouble(42); }
Trouble makeTrouble() { return 42; }

int main()
{
  auto o1 = makeTroubleObject();
  auto o2 = makeTrouble();

  return 0;
}

Build it with
g++ -std=c+=14 -g a.C

I expect I should get a compilation error in this line as the constructor is explicit. 

"Trouble makeTrouble() { return 42; }"

But it compiles fine, and even worse, it seems the object "o2" was not constructed properly thus I got a core dump.


This affects our adoption of Dev toolset 6.0.


Version-Release number of selected component (if applicable):

gcc version 6.2.1 20160916 (Red Hat 6.2.1-3) (GCC) 


How reproducible:

Always

Steps to Reproduce:
1. compile test program
2. execute compiled test
3. boom.

Actual results:

<snip>
[fmhirtz@ivanova ~]$ g++ --std=c++14 -g a.C -g
[fmhirtz@ivanova ~]$ ./a.out 
int
Segmentation fault (core dumped)
</snip>

Expected results:

Compilation failure likely.

Additional info:

This is impacting the client's ability to migrate to DTS6 so it's a priority.

Comment 11 Michael Petlan 2017-09-15 09:19:24 UTC
Successfully reproduced with DTS-6 (no fail) and verified with DTS-7 (devtoolset-7-gcc-7.2.1-1.el{6,7}).

VERIFIED

Comment 13 errata-xmlrpc 2017-10-24 09:47:20 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2017:3016