[LLVMbugs] [Bug 17908] New: Question about using blocks and modifier __block.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Nov 13 02:35:10 PST 2013


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

            Bug ID: 17908
           Summary: Question about using blocks and modifier __block.
           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/20131113/7515e2f6/attachment.html>


More information about the llvm-bugs mailing list