This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug objc++/57607] New: g++ cannot distinguish obj-c message call from c++11 lambda
- From: "antonbachin at yahoo dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 13 Jun 2013 17:56:59 +0000
- Subject: [Bug objc++/57607] New: g++ cannot distinguish obj-c message call from c++11 lambda
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57607
Bug ID: 57607
Summary: g++ cannot distinguish obj-c message call from c++11
lambda
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: objc++
Assignee: unassigned at gcc dot gnu.org
Reporter: antonbachin at yahoo dot com
The following program (test.mm) has both a lambda and a message call:
#import <cstdlib>
#import <iostream>
#import <Foundation/NSString.h>
int main()
{
[] () { std::cout << "Hello world!" << std::endl; }();
std::cout << [@"Hello world!" UTF8String] << std::endl;
return EXIT_SUCCESS;
}
Compiling with gcc 4.8.1 results in:
> g++-mp-4.8 -std=c++11 test.mm && ./a.out
test.mm: In function 'int main()':
test.mm:8:6: error: expected identifier before ']' token
[] () { std::cout << "Hello world!" << std::endl; }();
^
test.mm:8:6: error: '<expression error>' is not an Objective-C class name
or
alias
test.mm:8:6: error: objective-c++ message argument(s) are expected before
']' token
test.mm:8:11: error: expected ';' before '{' token
[] () { std::cout << "Hello world!" << std::endl; }();
^
test.mm:8:57: error: expected primary-expression before ')' token
[] () { std::cout << "Hello world!" << std::endl; }();
^
(I know that this wouldn't link, but I'm not getting that far). Meanwhile, with
clang:
> clang++ -std=c++11 -framework Foundation test.mm && ./a.out
Hello world!
Hello world!
Version information:
> g++-mp-4.8 --version
g++-mp-4.8 (MacPorts gcc48 4.8.1_0) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> clang++ --version
Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.4.0
Thread model: posix
Compiling with -Wall -Wextra makes no difference in the output for either
compiler.