You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Duru Can Celasun (Jira)" <ji...@apache.org> on 2020/04/28 06:24:00 UTC
[jira] [Resolved] (THRIFT-5179) Thrift compiler will generate wrong
code if IDL struct's name is 'a' or 'b'
[ https://issues.apache.org/jira/browse/THRIFT-5179?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Duru Can Celasun resolved THRIFT-5179.
--------------------------------------
Fix Version/s: 0.14.0
Resolution: Fixed
> Thrift compiler will generate wrong code if IDL struct's name is 'a' or 'b'
> ----------------------------------------------------------------------------
>
> Key: THRIFT-5179
> URL: https://issues.apache.org/jira/browse/THRIFT-5179
> Project: Thrift
> Issue Type: Bug
> Components: C++ - Compiler
> Reporter: Zezeng Wang
> Assignee: Zezeng Wang
> Priority: Minor
> Fix For: 0.14.0
>
>
> test.thrift file is as below:
> struct a {
> 1: string name,
> 2: double price
> }
> struct b {
> 1: i8 size,
> 2: i32 seq
> }
> struct a1 {
> 1: i8 size,
> 2: i32 seq
> }
> struct a2 {
> 1: i8 size,
> 2: i32 seq
> }
> When struct is named as 'a' or 'b' will throw compile errors as below:
> In file included from test_constants.h:10:0,
> from test_constants.cpp:7:
> test_types.h:76:17: error: ‘a’ is not a type
> void swap(a &a, a &b);
> ^
> In file included from test_types.cpp:7:0:
> test_types.h:76:17: error: ‘a’ is not a type
> void swap(a &a, a &b);
> ^
> test_types.cpp:102:17: error: ‘a’ is not a type
> void swap(a &a, a &b) {
> ^
> test_types.cpp: In function ‘void swap(a&, int&)’:
> test_types.cpp:104:18: error: request for member ‘name’ in ‘b’, which is of non-class type ‘int’
> swap(a.name, b.name);
> ^~~~
> test_types.cpp:105:19: error: request for member ‘price’ in ‘b’, which is of non-class type ‘int’
> swap(a.price, b.price);
> ^~~~~
> test_types.cpp:106:21: error: request for member ‘__isset’ in ‘b’, which is of non-class type ‘int’
> swap(a.__isset, b.__isset);
> ^~~~~~~
--
This message was sent by Atlassian Jira
(v8.3.4#803005)