[LLVMbugs] [Bug 17597] New: The code using blocks and modifier __block that compiles successfully in clang from XCode 5.0, but fails in previous.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Oct 16 04:44:02 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=17597

            Bug ID: 17597
           Summary: The code using blocks and modifier __block that
                    compiles successfully in clang from XCode 5.0, but
                    fails in previous.
           Product: clang
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: konevaanna2012 at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Dear Sirs!
I am Anna Koneva, a software developer from Moscow, Russia.

Below is the code, where we try to use a variable declared outside the block of
type std::ifstream inside the block.

__block std::ifstream file("/tmp/bar") ;
// We’ll try with and without a qualifier __block
void (^block)() = ^{
  file.rdbuf();
  file.close();
  file.open("/tmp/bar");
};
block();

1. If we declare the variable with the qualifier __block, we’ll get the
following error message (Clang, XCode 4.2):

«main.mm:28:27: Call to implicitly-deleted copy constructor of 'std::ifstream'
(aka 'basic_ifstream<char>')»

BUT! On the latest clang (XCode 5.0) we do not get an error message and this
code compiles successfully.



By the way...

2. If without this modifier (__block), then the other error occurs:

«main.mm:31:9: Call to implicitly-deleted copy constructor of 'const
std::ifstream' (aka 'const basic_ifstream<char>')

main.mm:32:9: Member function 'close' not viable: 'this' argument has type
'const std::ifstream' (aka 'const basic_ifstream<char>'), but function is not
marked const»

This behavior is the same for both clang (XCode 4.6.2 and new XCode 5.0).

So please tell me, is it a correct behavior for the first case in XCode 5.0?

Best regards,
Anna.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131016/c28a9e7b/attachment.html>


More information about the llvm-bugs mailing list