| Summary: | Internal compiler error in resolve_offset_ref, at cp/init.c:1886 when using the function pointer in class | ||
|---|---|---|---|
| Product: | [Retired] Red Hat Developer Program | Reporter: | dinesh tailor <dineshkumar.tailor> |
| Component: | ABE | Assignee: | Jim Whitehurst <jim> |
| Status: | CLOSED EOL | QA Contact: | Michael Waite <mwaite> |
| Severity: | medium | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | beta | ||
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | i386 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2020-03-27 18:38:46 UTC | Type: | --- |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
Description of problem: This is the my test program for function,How to use the function pointer in class in c++ -----------------------code for 1.cpp--------------------------- #include<iostream.h> class abc { public : int add(int a,int b) { cout<<"Calling Add function with "<<a<< " and " <<b<<"\n"; return (a+b); } int sub(int a,int b) { cout<<"Calling sub function with "<<a<< " and " <<b<<"\n"; return (a-b); } }; int add(int a,int b) { cout<<"Calling Add without class function with "<<a<< " and " <<b<<"\n"; return (a+b); } int sub(int a,int b) { cout<<"Calling sub without class function with "<<a<< " and " <<b<<"\n"; return (a-b); } int main() { int (*f1)(int,int); f1=&add; abc a; int (abc::*f2)(int,int)=&(abc::add); //cout<<"In main "<<a.*f2(3,4)<<"\n"; a.*f2(3,4); return 0; } -----------------------end of code for 1.cpp--------------------------- when i comple the code it is giving error In file included from /usr/include/c++/3.2/backward/iostream.h:31, from 1.cpp:1: /usr/include/c++/3.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated. 1.cpp: In function `int main()': 1.cpp:33: Internal compiler error in resolve_offset_ref, at cp/init.c:1886 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://bugzilla.redhat.com/bugzilla/> for instructions. and when i changed line as int (abc::*f2)(int,int)=&abc::add; //I think it should work but i am getting error 1.cpp: In function `int main()': 1.cpp:36: pointer to member function called, but not in class scope Version-Release number of selected component (if applicable): I am using g++ gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7) How reproducible: you compile code on above g++ version then it will give error. Steps to Reproduce: 1. 2. 3. Actual results: it is giving the internal compiler error Expected results: it should compile the code. Additional info: