Using ^blocks with C++ STL causes segfault in g++?!

Discussion in 'Mac Programming' started by thexaq, Apr 20, 2010.

  1. thexaq macrumors newbie

    Apr 20, 2010
    Apple's own version of g++ (v4.2.1) segfaults when I compile the following simple program combining block objects and the C++ Standard Template Library. This is a problem for me since I was hoping to use Grand Central Dispatch with my existing C++ code!

    #include <vector>
    int main () {
    	typedef std::vector<int> returnType;   [COLOR="SeaGreen"]// Define return type for block. Causes error.[/COLOR]
    	//typedef int returnType;   [COLOR="SeaGreen"]// (No error with this definition instead)[/COLOR]
    	returnType (^blockFcn)();  [COLOR="SeaGreen"]// declare variable of block type[/COLOR]
    	blockFcn = ^(){ returnType x; return x; };  [COLOR="SeaGreen"]// define the block[/COLOR]
    	returnType test = blockFcn();	  [COLOR="SeaGreen"]// run the block[/COLOR]
    	return 0;
    Results of compiling this code is "i686-apple-darwin10-g++-4.2.1: Internal error: Segmentation fault (program cc1plus)." Anyone have any clue what's going on, and how to fix it?

    Cheers and thanks!
  2. Cromulent macrumors 603


    Oct 2, 2006
    The Land of Hope and Glory
    I'd suggest doing as the message states and reporting it as a bug to Apple.
  3. thexaq thread starter macrumors newbie

    Apr 20, 2010
    Yep, already done.
  4. kainjow Moderator emeritus


    Jun 15, 2000
    heh, Xcode fail :D

    Attached Files:

Share This Page