error: cannot initialize a variable of type 'NSBitmapImageFileType' with an rvalue of type 'nullptr_t'

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? Thanks in advance for any clarifications.

Jack

As far as I can tell, NSBitmapImageFileType is an enum. So no.

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

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

[snip]

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?

You should probably explicitly initialize it to an appropriate value or fix the code to not use it in the case clang is warning about, but it's not hard to initialize a strongly-typed enum to *something*:

   MyEnum value{};

- Jim