This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 1300154 - g++ internal error during compilation of a small C++ code using c++14 flag
g++ internal error during compilation of a small C++ code using c++14 flag
Status: NEW
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: gcc (Show other bugs)
3.9
x86_64 Linux
unspecified Severity high
: rc
: ---
Assigned To: Jakub Jelinek
qe-baseos-tools
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2016-01-19 23:42 EST by suva_aich
Modified: 2016-01-27 21:17 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description suva_aich 2016-01-19 23:42:09 EST
Description of problem:
Failure to compile

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

How reproducible:
Always

Steps to Reproduce:
1. g++ -std=c++14 -o main main.cpp
2.
3.

Actual results:
Compilation failure

Expected results:
Compilation successful

Additional info:
Here are the details:
++++++++++++++++++++++++++++++++

sh-4.3$ uname -a                                                                                                                                                                                                                   
Linux 3d3bbe0ea6c3 3.10.0-123.20.1.el7.x86_64 #1 SMP Thu Jan 29 18:05:33 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux                                                                                                                   
sh-4.3$ g++ -v                                                                                                                                                                                                                     
Using built-in specs.                                                                                                                                                                                                              
COLLECT_GCC=g++                                                                                                                                                                                                                    
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.9.2/lto-wrapper                                                                                                                                                         
Target: x86_64-redhat-linux                                                                                                                                                                                                        
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=releas 
e --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,fortran,ada,go, 
lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.9.2-20141101/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.9.2-20141101/obj-x86_64-redhat-linux 
/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux                                                                                                                  
Thread model: posix                                                                                                                                                                                                                
gcc version 4.9.2 20141101 (Red Hat 4.9.2-1) (GCC)                                                                                                                                                                                 
sh-4.3$                                                                                                                                                                                                                            
sh-4.3$ cat main.cpp                                                                                                                                                                                                               
#include <iostream>                                                                                                                                                                                                                
#include <regex>                                                                                                                                                                                                                   
#include <string>                                                                                                                                                                                                                  
                                                                                                                                                                                                                                   
                                                                                                                                                                                                                                   
int main()                                                                                                                                                                                                                         
{                                                                                                                                                                                                                                  
   std::string data = "<person>\n"                                                                                                                                                                                                 
                      "<first>John</first>"                                                                                                                                                                                        
                      "<last>Major</last>"                                                                                                                                                                                         
                      "<company>\n"                                                                                                                                                                                                
                      "<name>Mars</name>";                                                                                                                                                                                         
                                                                                                                                                                                                                                   
    std::regex reg("<(.*)>(.*)</(\\1.*)>)");                                                                                                                                                                                       
                                                                                                                                                                                                                                   
    auto pos = data.cbegin();                                                                                                                                                                                                      
    auto end = data.cend();                                                                                                                                                                                                        
    std::smatch m;                                                                                                                                                                                                                 
                                                                                                                                                                                                                                   
    for (; std::regex_search (pos, end, m, reg); pos = m.suffix().first)                                                                                                                                                           
    {                                                                                                                                                                                                                              
       std::cout << "match : " << m.str() << std::endl;                                                                                                                                                                            
       std::cout << "tag : " << m.str(1) << std::endl;                                                                                                                                                                             
       std::cout << "value : " << m.str(2) << std::endl;                                                                                                                                                                           
    }                                                                                                                                                                                                                              
                                                                                                                                                                                                                                   
                                                                                                                                                                                                                                   
   return 0;                                                                                                                                                                                                                       
}                                                                                                                                                                                                
                                                                                                                                                                                                                                   
sh-4.3$                                                                                                                                                                                                                            
sh-4.3$ g++ -std=c++14 -o main main.cpp                                                                                                                                                                                            
g++: internal compiler error: Killed (program cc1plus)                                                                                                                                                                             
Please submit a full bug report,                                                                                                                                                                                                   
with preprocessed source if appropriate.                                                                                                                                                                                           
See <http://bugzilla.redhat.com/bugzilla> for instructions.                                                                                                                                                                        
sh-4.3$ 

++++++++++++++++++++++++++++++++++++++++++++
Comment 1 Jakub Jelinek 2016-01-20 02:40:31 EST
RHEL 3 never shipped gcc 4.9.2-1, but I believe Developer Toolset 3 also has not shipped 4.9.2-1, just 4.9.2-6 or 4.9.1-*.  So, please clarify what compiler and OS version you are actually using, rpm -qf `which g++` glibc kernel etc.
Furthermore, 
g++: internal compiler error: Killed (program cc1plus)
is something out of g++ control, it means the kernel has killed the program, so most likely you don't have enough memory to compile it.  It would be a bug only if it needed unreasonable amount of memory compared to the complexity of the source.  As you haven't stated what source and version of packages you are using, it is impossible to recreate it, we'd need preprocessed source plus know which compiler you're using, all I can say is that with g++ 5.3.1 the testcase compiles just fine with reasonable amount of memory and compile time.
Comment 2 suva_aich 2016-01-27 21:17:36 EST
Couple of points :

1) There was a syntax error in following line:

   std::regex reg("<(.*)>(.*)</(\\1.*)>)");

should be:

   std::regex reg("<(.*)>(.*)</(\\1.*)>");  

Even then the problem of internal compiler failure persist.

2) This problem was generated on a publicly available g++ env. This is how you can reproduce:
 i) go to : http://www.tutorialspoint.com/compile_cpp11_online.php
ii) select -std=c++14 option under Project -> Compile Options

3) Copy paste the program & hit compile.

4) The uname -a and g++ -v commands can be run in the provided Terminal window. The RHEL distro and g++ -v option was just copy pasted from there. Also the preprocessed version can be generated quite easily.

5) It may be a memory issue as this program runs without problem in other g++ env, such as, in www.cpp.sh, not sure whether they are running Red Hat though.

Note You need to log in before you can comment on or make changes to this bug.