[cfe-dev] error: cannot initialize a variable of type 'NSBitmapImageFileType' with an rvalue of type 'nullptr_t'

Jack Howarth howarth.mailing.lists at gmail.com
Mon Apr 20 15:52:23 PDT 2015


Richard,
        While removing the initialization of imageFileType with nil
compiles under clang 3.6.0svn, the compilation now emits warnings later in
the file...

/sw/src/fink.build/rstudio-desktop-0.98.1103-4/rstudio-0.98.1103/src/cpp/desktop-mac/GwtCallbacks.mm:621:13:
warning: variable 'imageFileType' is
      used uninitialized whenever 'if' condition is false
[-Wsometimes-uninitialized]
   else if ([format isEqualToString: @"tiff"])
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/sw/src/fink.build/rstudio-desktop-0.98.1103-4/rstudio-0.98.1103/src/cpp/desktop-mac/GwtCallbacks.mm:630:54:
note: uninitialized use occurs here
   NSData *data = [imageRep representationUsingType: imageFileType
properties: properties];
                                                     ^~~~~~~~~~~~~
/sw/src/fink.build/rstudio-desktop-0.98.1103-4/rstudio-0.98.1103/src/cpp/desktop-mac/GwtCallbacks.mm:621:9:
note: remove the 'if' if its
      condition is always true
   else if ([format isEqualToString: @"tiff"])
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/sw/src/fink.build/rstudio-desktop-0.98.1103-4/rstudio-0.98.1103/src/cpp/desktop-mac/GwtCallbacks.mm:609:4:
note: variable 'imageFileType' is
      declared here
   NSBitmapImageFileType imageFileType;
   ^

So you are saying that under -std=c++11, it is impossible to initialize the
strongly typed enum imageFileType in order to suppress these warnings?
                 Jack

On Mon, Apr 20, 2015 at 6:41 PM, Richard Smith <richard at metafoo.co.uk>
wrote:

> On Mon, Apr 20, 2015 at 3:01 PM, Jack Howarth <
> howarth.mailing.lists at gmail.com> wrote:
>
>>    I am running into an error in clang 3.6.0svn with the line...
>>
>>    NSBitmapImageFileType imageFileType = nil;
>>
>> producing an error of...
>>
>> /sw/src/fink.build/rstudio-desktop-0.98.1103-4/rstudio-0.98.1103/src/cpp/desktop-mac/GwtCallbacks.mm:609:26:
>> error: cannot initialize a variable of type 'NSBitmapImageFileType' with an
>>       rvalue of type 'nullptr_t'
>>    NSBitmapImageFileType imageFileType = nil;
>>                          ^               ~~~
>>
>> when -std=c++11 is used. Is this an glitch in the compiler? According
>> to...
>>
>>
>> http://www.cprogramming.com/c++11/c++11-nullptr-strongly-typed-enum-class.html
>>
>> shouldn't I I be able to initialize it with std::nullptr_t?
>>
>
> As far as I can tell, NSBitmapImageFileType is an enum. So no.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150420/94f6b18b/attachment.html>


More information about the cfe-dev mailing list