You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Zezeng Wang (Jira)" <ji...@apache.org> on 2020/05/11 03:41:00 UTC
[jira] [Updated] (THRIFT-5200) Thrift compiler will generate
incorrect code when add 'cob_style' option.
[ https://issues.apache.org/jira/browse/THRIFT-5200?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Zezeng Wang updated THRIFT-5200:
--------------------------------
Description:
Step to produce the bug:
1. Generate 'cob_style' code by command:
thrift -r --gen cpp:cob_style StressTest.thrift
2.Add main function in Service_async_server.skeleton.cpp file(the default async file doesn't generate main function):
I just add an simple empty main function to ensure the program has an entrance:
//generate code ...
int main()
{
return 0;
}
3. Compile it by command:
g++ Service_async_server.skeleton.cpp Service.cpp -o asyncServer -lthrift
result:
compile error and output:
Service_async_server.skeleton.cpp:72:19: error: ‘ServiceHandler’ was not declared in this scope
std::unique_ptr<ServiceHandler> syncHandler_;
^~~~~~~~~~~~~~
Service_async_server.skeleton.cpp:72:19: note: suggested alternative: ‘ServiceAsyncHandler’
std::unique_ptr<ServiceHandler> syncHandler_;
^~~~~~~~~~~~~~
ServiceAsyncHandler
Service_async_server.skeleton.cpp:72:33: error: template argument 1 is invalid
std::unique_ptr<ServiceHandler> syncHandler_;
^
Service_async_server.skeleton.cpp:72:33: error: template argument 2 is invalid
Service_async_server.skeleton.cpp: In constructor ‘ServiceAsyncHandler::ServiceAsyncHandler()’:
Service_async_server.skeleton.cpp:19:36: error: ‘ServiceHandler’ was not declared in this scope
syncHandler_ = std::unique_ptr<ServiceHandler>(new ServiceHandler);
^~~~~~~~~~~~~~
Service_async_server.skeleton.cpp:19:36: note: suggested alternative: ‘ServiceAsyncHandler’
syncHandler_ = std::unique_ptr<ServiceHandler>(new ServiceHandler);
^~~~~~~~~~~~~~
ServiceAsyncHandler
Service_async_server.skeleton.cpp:19:50: error: template argument 1 is invalid
syncHandler_ = std::unique_ptr<ServiceHandler>(new ServiceHandler);
^
Service_async_server.skeleton.cpp:19:50: error: template argument 2 is invalid
Service_async_server.skeleton.cpp:19:56: error: ‘ServiceHandler’ does not name a type; did you mean ‘ServiceAsyncHandler’?
syncHandler_ = std::unique_ptr<ServiceHandler>(new ServiceHandler);
^~~~~~~~~~~~~~
ServiceAsyncHandler
Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoVoid(std::function<void()>)’:
Service_async_server.skeleton.cpp:25:17: error: base operand of ‘->’ is not a pointer
syncHandler_->echoVoid();
^~
Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoByte(std::function<void(const signed char&)>, int8_t)’:
Service_async_server.skeleton.cpp:31:27: error: base operand of ‘->’ is not a pointer
_return = syncHandler_->echoByte(arg);
^~
Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoI32(std::function<void(const int&)>, int32_t)’:
Service_async_server.skeleton.cpp:37:27: error: base operand of ‘->’ is not a pointer
_return = syncHandler_->echoI32(arg);
^~
Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoI64(std::function<void(const long int&)>, int64_t)’:
Service_async_server.skeleton.cpp:43:27: error: base operand of ‘->’ is not a pointer
_return = syncHandler_->echoI64(arg);
^~
Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoString(std::function<void(const std::__cxx11::basic_string<char>&)>, const string&)’:
Service_async_server.skeleton.cpp:49:17: error: base operand of ‘->’ is not a pointer
syncHandler_->echoString(_return, arg);
^~
Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoList(std::function<void(const std::vector<signed char>&)>, const std::vector<signed char>&)’:
Service_async_server.skeleton.cpp:55:17: error: base operand of ‘->’ is not a pointer
syncHandler_->echoList(_return, arg);
^~
Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoSet(std::function<void(const std::set<signed char>&)>, const std::set<signed char>&)’:
Service_async_server.skeleton.cpp:61:17: error: base operand of ‘->’ is not a pointer
syncHandler_->echoSet(_return, arg);
^~
Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoMap(std::function<void(const std::map<signed char, signed char>&)>, const std::map<signed char, signed char>&)’:
Service_async_server.skeleton.cpp:67:17: error: base operand of ‘->’ is not a pointer
syncHandler_->echoMap(_return, arg);
^~
expected result:
compile ok and generate an excutable file;
StressTest.thrift file content is as below:
namespace cpp test.stress
service Service {
void echoVoid(),
i8 echoByte(1: i8 arg),
i32 echoI32(1: i32 arg),
i64 echoI64(1: i64 arg),
string echoString(1: string arg),
list<i8> echoList(1: list<i8> arg),
set<i8> echoSet(1: set<i8> arg),
map<i8, i8> echoMap(1: map<i8, i8> arg)
}
was:
Step to produce the bug:
1. Generate 'cob_style' code by command:
thrift -r --gen cpp:cob_style StressTest.thrift
2.Add main function in Service_async_server.skeleton.cpp file(the default async file doesn't generate main function):
I just add an simple empty main function to ensure the program has an entrance:
//generate code ...
int main()
{
return 0;
}
3. Compile it by command:
g++ Service_async_server.skeleton.cpp Service.cpp -o asyncServer -lthrift
result:
compile error and output:
Service_async_server.skeleton.cpp:72:19: error: ‘ServiceHandler’ was not declared in this scope
std::unique_ptr<ServiceHandler> syncHandler_;
^~~~~~~~~~~~~~
Service_async_server.skeleton.cpp:72:19: note: suggested alternative: ‘ServiceAsyncHandler’
std::unique_ptr<ServiceHandler> syncHandler_;
^~~~~~~~~~~~~~
ServiceAsyncHandler
Service_async_server.skeleton.cpp:72:33: error: template argument 1 is invalid
std::unique_ptr<ServiceHandler> syncHandler_;
^
Service_async_server.skeleton.cpp:72:33: error: template argument 2 is invalid
Service_async_server.skeleton.cpp: In constructor ‘ServiceAsyncHandler::ServiceAsyncHandler()’:
Service_async_server.skeleton.cpp:19:36: error: ‘ServiceHandler’ was not declared in this scope
syncHandler_ = std::unique_ptr<ServiceHandler>(new ServiceHandler);
^~~~~~~~~~~~~~
Service_async_server.skeleton.cpp:19:36: note: suggested alternative: ‘ServiceAsyncHandler’
syncHandler_ = std::unique_ptr<ServiceHandler>(new ServiceHandler);
^~~~~~~~~~~~~~
ServiceAsyncHandler
Service_async_server.skeleton.cpp:19:50: error: template argument 1 is invalid
syncHandler_ = std::unique_ptr<ServiceHandler>(new ServiceHandler);
^
Service_async_server.skeleton.cpp:19:50: error: template argument 2 is invalid
Service_async_server.skeleton.cpp:19:56: error: ‘ServiceHandler’ does not name a type; did you mean ‘ServiceAsyncHandler’?
syncHandler_ = std::unique_ptr<ServiceHandler>(new ServiceHandler);
^~~~~~~~~~~~~~
ServiceAsyncHandler
Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoVoid(std::function<void()>)’:
Service_async_server.skeleton.cpp:25:17: error: base operand of ‘->’ is not a pointer
syncHandler_->echoVoid();
^~
Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoByte(std::function<void(const signed char&)>, int8_t)’:
Service_async_server.skeleton.cpp:31:27: error: base operand of ‘->’ is not a pointer
_return = syncHandler_->echoByte(arg);
^~
Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoI32(std::function<void(const int&)>, int32_t)’:
Service_async_server.skeleton.cpp:37:27: error: base operand of ‘->’ is not a pointer
_return = syncHandler_->echoI32(arg);
^~
Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoI64(std::function<void(const long int&)>, int64_t)’:
Service_async_server.skeleton.cpp:43:27: error: base operand of ‘->’ is not a pointer
_return = syncHandler_->echoI64(arg);
^~
Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoString(std::function<void(const std::__cxx11::basic_string<char>&)>, const string&)’:
Service_async_server.skeleton.cpp:49:17: error: base operand of ‘->’ is not a pointer
syncHandler_->echoString(_return, arg);
^~
Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoList(std::function<void(const std::vector<signed char>&)>, const std::vector<signed char>&)’:
Service_async_server.skeleton.cpp:55:17: error: base operand of ‘->’ is not a pointer
syncHandler_->echoList(_return, arg);
^~
Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoSet(std::function<void(const std::set<signed char>&)>, const std::set<signed char>&)’:
Service_async_server.skeleton.cpp:61:17: error: base operand of ‘->’ is not a pointer
syncHandler_->echoSet(_return, arg);
^~
Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoMap(std::function<void(const std::map<signed char, signed char>&)>, const std::map<signed char, signed char>&)’:
Service_async_server.skeleton.cpp:67:17: error: base operand of ‘->’ is not a pointer
syncHandler_->echoMap(_return, arg);
^~
expected result:
compile ok and generate an excutable file;
> Thrift compiler will generate incorrect code when add 'cob_style' option.
> -------------------------------------------------------------------------
>
> Key: THRIFT-5200
> URL: https://issues.apache.org/jira/browse/THRIFT-5200
> Project: Thrift
> Issue Type: Bug
> Components: C++ - Compiler
> Reporter: Zezeng Wang
> Priority: Major
>
> Step to produce the bug:
> 1. Generate 'cob_style' code by command:
> thrift -r --gen cpp:cob_style StressTest.thrift
> 2.Add main function in Service_async_server.skeleton.cpp file(the default async file doesn't generate main function):
> I just add an simple empty main function to ensure the program has an entrance:
> //generate code ...
> int main()
> {
> return 0;
> }
> 3. Compile it by command:
> g++ Service_async_server.skeleton.cpp Service.cpp -o asyncServer -lthrift
> result:
> compile error and output:
> Service_async_server.skeleton.cpp:72:19: error: ‘ServiceHandler’ was not declared in this scope
> std::unique_ptr<ServiceHandler> syncHandler_;
> ^~~~~~~~~~~~~~
> Service_async_server.skeleton.cpp:72:19: note: suggested alternative: ‘ServiceAsyncHandler’
> std::unique_ptr<ServiceHandler> syncHandler_;
> ^~~~~~~~~~~~~~
> ServiceAsyncHandler
> Service_async_server.skeleton.cpp:72:33: error: template argument 1 is invalid
> std::unique_ptr<ServiceHandler> syncHandler_;
> ^
> Service_async_server.skeleton.cpp:72:33: error: template argument 2 is invalid
> Service_async_server.skeleton.cpp: In constructor ‘ServiceAsyncHandler::ServiceAsyncHandler()’:
> Service_async_server.skeleton.cpp:19:36: error: ‘ServiceHandler’ was not declared in this scope
> syncHandler_ = std::unique_ptr<ServiceHandler>(new ServiceHandler);
> ^~~~~~~~~~~~~~
> Service_async_server.skeleton.cpp:19:36: note: suggested alternative: ‘ServiceAsyncHandler’
> syncHandler_ = std::unique_ptr<ServiceHandler>(new ServiceHandler);
> ^~~~~~~~~~~~~~
> ServiceAsyncHandler
> Service_async_server.skeleton.cpp:19:50: error: template argument 1 is invalid
> syncHandler_ = std::unique_ptr<ServiceHandler>(new ServiceHandler);
> ^
> Service_async_server.skeleton.cpp:19:50: error: template argument 2 is invalid
> Service_async_server.skeleton.cpp:19:56: error: ‘ServiceHandler’ does not name a type; did you mean ‘ServiceAsyncHandler’?
> syncHandler_ = std::unique_ptr<ServiceHandler>(new ServiceHandler);
> ^~~~~~~~~~~~~~
> ServiceAsyncHandler
> Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoVoid(std::function<void()>)’:
> Service_async_server.skeleton.cpp:25:17: error: base operand of ‘->’ is not a pointer
> syncHandler_->echoVoid();
> ^~
> Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoByte(std::function<void(const signed char&)>, int8_t)’:
> Service_async_server.skeleton.cpp:31:27: error: base operand of ‘->’ is not a pointer
> _return = syncHandler_->echoByte(arg);
> ^~
> Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoI32(std::function<void(const int&)>, int32_t)’:
> Service_async_server.skeleton.cpp:37:27: error: base operand of ‘->’ is not a pointer
> _return = syncHandler_->echoI32(arg);
> ^~
> Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoI64(std::function<void(const long int&)>, int64_t)’:
> Service_async_server.skeleton.cpp:43:27: error: base operand of ‘->’ is not a pointer
> _return = syncHandler_->echoI64(arg);
> ^~
> Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoString(std::function<void(const std::__cxx11::basic_string<char>&)>, const string&)’:
> Service_async_server.skeleton.cpp:49:17: error: base operand of ‘->’ is not a pointer
> syncHandler_->echoString(_return, arg);
> ^~
> Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoList(std::function<void(const std::vector<signed char>&)>, const std::vector<signed char>&)’:
> Service_async_server.skeleton.cpp:55:17: error: base operand of ‘->’ is not a pointer
> syncHandler_->echoList(_return, arg);
> ^~
> Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoSet(std::function<void(const std::set<signed char>&)>, const std::set<signed char>&)’:
> Service_async_server.skeleton.cpp:61:17: error: base operand of ‘->’ is not a pointer
> syncHandler_->echoSet(_return, arg);
> ^~
> Service_async_server.skeleton.cpp: In member function ‘virtual void ServiceAsyncHandler::echoMap(std::function<void(const std::map<signed char, signed char>&)>, const std::map<signed char, signed char>&)’:
> Service_async_server.skeleton.cpp:67:17: error: base operand of ‘->’ is not a pointer
> syncHandler_->echoMap(_return, arg);
> ^~
> expected result:
> compile ok and generate an excutable file;
> StressTest.thrift file content is as below:
> namespace cpp test.stress
> service Service {
> void echoVoid(),
> i8 echoByte(1: i8 arg),
> i32 echoI32(1: i32 arg),
> i64 echoI64(1: i64 arg),
> string echoString(1: string arg),
> list<i8> echoList(1: list<i8> arg),
> set<i8> echoSet(1: set<i8> arg),
> map<i8, i8> echoMap(1: map<i8, i8> arg)
> }
--
This message was sent by Atlassian Jira
(v8.3.4#803005)