Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-5200

Thrift compiler will generate incorrect code when add 'cob_style' option.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.14.0
    • C++ - Compiler
    • None

    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;

      Attachments

        1. StressTest.thrift
          0.3 kB
          Zezeng Wang

        Issue Links

          Activity

            People

              zeshuai007 Zezeng Wang
              zeshuai007 Zezeng Wang
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m