0

My OS is macOS and I am using homebrew g++ compiler for executing cpp files

Code :

#include<bits/stdc++.h>
using namespace std;
int main(){
    map<pair<char,char>,int> mp;
    pair<char,char> p={'a','b'};
    mp[p]++;
    cout<<"yes"<<endl;
}

Error :

0  0x1004dc1a0  __assert_rtn + 140
1  0x100363a8c  mach_o::relocatable::Parser<arm64>::parse(mach_o::relocatable::ParserOptions const&) + 4536
2  0x100335d38  mach_o::relocatable::Parser<arm64>::parse(unsigned char const*, unsigned long long, char const*, long, ld::File::Ordinal, mach_o::relocatable::ParserOptions const&) + 148
3  0x10039e4ac  ld::tool::InputFiles::makeFile(Options::FileInfo const&, bool) + 1468
4  0x1003a1360  ___ZN2ld4tool10InputFilesC2ER7Options_block_invoke + 56
5  0x195ac81f4  _dispatch_client_callout2 + 20
6  0x195adb954  _dispatch_apply_invoke + 224
7  0x195ac81b4  _dispatch_client_callout + 20
8  0x195ad9a04  _dispatch_root_queue_drain + 680
9  0x195ada104  _dispatch_worker_thread2 + 164
10  0x195c88324  _pthread_wqthread + 228
A linker snapshot was created at:
    /tmp/sk-2022-09-26-013526.ld-snapshot
ld: Assertion failed: (_file->_atomsArrayCount == computedAtomCount && "more atoms allocated than expected"), function parse, file macho_relocatable_file.cpp, line 2061.
collect2: error: ld returned 1 exit status

My compiler info :

g++ (Homebrew GCC 12.2.0) 12.2.0
Copyright (C) 2022 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.

Code is executing in all the online editors. But not with home brew compiler what could be the reason ?

  • Have you installed homebrew g++ in favor of `#include`? – 273K Sep 25 '22 at 20:21
  • 1
    See [Why should I not #include ?](https://stackoverflow.com/q/31816095) and [Why using namespace std is bad practice](https://stackoverflow.com/questions/1452721). – prapin Sep 25 '22 at 20:33
  • 1
    Since the release of Xcode 14, this is a recurring problem on people trying to use GCC with Homebrew. – prapin Sep 25 '22 at 20:35
  • 1
    `#include` -- I am convinced that no one actually types this in by hand off the top of their head, and instead, just blindly copied and pasted this from a poor C++ "competitive coding" website into the program -- the slashes, the placement of the `++` and the `.`, etc. Do not use this non-standard include file -- instead it should be `#include ` and then `#include `. – PaulMcKenzie Sep 25 '22 at 20:44

0 Answers0