You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by klazuka <gi...@git.apache.org> on 2014/08/26 01:04:13 UTC

[GitHub] thrift pull request: THRIFT-2676 Avoid 'i386' name collision in ge...

GitHub user klazuka opened a pull request:

    https://github.com/apache/thrift/pull/202

    THRIFT-2676 Avoid 'i386' name collision in generated Cocoa/objc code

    [THRIFT-2676](https://issues.apache.org/jira/browse/THRIFT-2676)
    
    This fixes a bug in the cocoa code generator where the variable
    used by a for-loop can conflict with a built-in symbol when the
    temporary variable counter is equal to 386. The generated variable
    name, 'i386', conflicts with a macro built-in to the compiler.
    
    I can reproduce this bug on Xcode 5 as well as Xcode 6. It appears
    to only affect iOS projects, not OS X projects.
    
    My fix simply prefixes the generated variable with 'idx' instead of 'i'.
    
    This test code demonstrates the problem, regardless of Thrift codegen.
    
    ```
    int i386 = 42;
    printf("foobar %d\n", i386);
    ```
    
    Which results in the following compiler error:
    
    ```
    /Users/keith/Desktop/ReservedSymbolTest/ReservedSymbolTest/ViewController.m:22:7: error: expected identifier or '('
      int i386 = 42;
          ^
    <built-in>:143:14: note: expanded from here
                 ^
    1 error generated.
    ```

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/klazuka/thrift THRIFT-2676-cocoa-gen-name-collision

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/thrift/pull/202.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #202
    
----
commit 4fc71285052ab04998d990a5de6b071ff53f3c47
Author: Keith Lazuka <kl...@acompli.com>
Date:   2014-08-25T22:31:49Z

    THRIFT-2676 Avoid 'i386' name collision in generated Cocoa/objc code
    
    This fixes a bug in the cocoa code generator where the variable
    used by a for-loop can conflict with a built-in symbol when the
    temporary variable counter is equal to 386. The generated variable
    name, 'i386', conflicts with a macro built-in to the compiler.
    
    I can reproduce this bug on Xcode 5 as well as Xcode 6. It appears
    to only affect iOS projects, not OS X projects.
    
    My fix simply prefixes the generated variable with 'idx' instead of 'i'.
    
    This test code demonstrates the problem, regardless of Thrift codegen.
    
        int i386 = 42;
        printf("foobar %d\n", i386);
    
    Which results in the following compiler error:
    
    /Users/keith/Desktop/ReservedSymbolTest/ReservedSymbolTest/ViewController.m:22:7: error: expected identifier or '('
      int i386 = 99;
          ^
    <built-in>:143:14: note: expanded from here
                 ^
    1 error generated.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] thrift pull request: THRIFT-2676 Avoid 'i386' name collision in ge...

Posted by jfarrell <gi...@git.apache.org>.
Github user jfarrell closed the pull request at:

    https://github.com/apache/thrift/pull/202


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] thrift pull request: THRIFT-2676 Avoid 'i386' name collision in ge...

Posted by jfarrell <gi...@git.apache.org>.
Github user jfarrell commented on the pull request:

    https://github.com/apache/thrift/pull/202#issuecomment-57349476
  
    closing pr due to patch being applied in commit e26a19bba0a91e31d0ec8092940992534426a26f


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---