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

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

  1. thexaq macrumors newbie

    Joined:
    Apr 20, 2010
    #1
    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!

    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!
    -xaq
     
  2. Cromulent macrumors 603

    Cromulent

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

    Joined:
    Apr 20, 2010
    #3
    Yep, already done.
     
  4. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
    heh, Xcode fail :D
     

    Attached Files:

Share This Page