https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119105

            Bug ID: 119105
           Summary: std::locale only working with C and POSIX
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: programmingkidx at gmail dot com
  Target Milestone: ---

Mac OS includes over 200 options for what std::locale can be set to. To view
this entire list run the command 'locale -a'. std::locale should be able to use
most or all of these locales. With g++ 14.2.0 std::locale fails most of the
time. Only the C and POSIX locales work.

This is the program used to set each locale. To build it run 'g++ main.cpp -o
program'.
To run this program on Mac OS use this command: 'locale -a | ./program'

#include <iostream>
#include <locale>
#include <stdexcept>

using namespace std;

int main() {
    string line, name;
    int i = 1, failures = 0, successes = 0;
    // Read each line from standard input until EOF
    while (getline(std::cin, line)) {
        try {
            name = line;
            cout << "Setting locale to " << name << " ";
            cout.imbue(locale(name));
            cout << fixed <<123456.789<< endl;
            successes++;
        }
        catch(exception &e) {
            cout << "Failed" << endl;
            failures++;
        }
    }
    cout << "Number of failures: " << failures << endl;
    cout << "Number of successes: " << successes << endl;
    return 0;
}

Using g++ 14.2.0 I see these results:
Number of failures: 201
Number of successes: 2

Using clang++ 13 and 19 I see these results:
Number of failures: 1
Number of successes: 202


g++ info:
Using built-in specs.
COLLECT_GCC=g++-mp-14
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/aarch64-apple-darwin21/14.2.0/lto-wrapper
Target: aarch64-apple-darwin21
Configured with:
/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_gcc14/gcc14/work/gcc-14.2.0/configure
--prefix=/opt/local --build=aarch64-apple-darwin21
--enable-languages=c,c++,objc,obj-c++,lto,fortran,jit
--libdir=/opt/local/lib/gcc14 --infodir=/opt/local/share/info
--mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-14
--with-local-prefix=/opt/local --with-system-zlib --disable-nls
--program-suffix=-mp-14 --with-gxx-include-dir=/opt/local/include/gcc14/c++/
--with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local
--with-isl=/opt/local --with-zstd=/opt/local --enable-checking=release
--disable-multilib --enable-lto --enable-libstdcxx-time
--with-build-config=bootstrap-debug --with-as=/opt/local/bin/as
--with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar
--with-bugurl=https://trac.macports.org/newticket --enable-host-shared
--with-darwin-extra-rpath=/opt/local/lib/libgcc
--with-libiconv-prefix=/opt/local --disable-tls
--with-gxx-libcxx-include-dir=/opt/local/libexec/gcc14/libc++/include/c++/v1
--with-pkgversion='MacPorts gcc14 14.2.0_1+stdlib_flag'
--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.2.0 (MacPorts gcc14 14.2.0_1+stdlib_flag) 
COLLECT_GCC_OPTIONS='-v' '-o' 'program' '-mmacosx-version-min=12.0.0'
'-asm_macosx_version_min=12.0' '-nodefaultexport' '-mcpu=apple-m1'
'-mlittle-endian' '-mabi=lp64' '-dumpdir' 'program-'
 /opt/local/libexec/gcc/aarch64-apple-darwin21/14.2.0/cc1plus -quiet -v
-D__DYNAMIC__ main.cpp -fPIC -quiet -dumpdir program- -dumpbase main.cpp
-dumpbase-ext .cpp -mmacosx-version-min=12.0.0 -mcpu=apple-m1 -mlittle-endian
-mabi=lp64 -version -o
/var/folders/25/26kqmfp91r1f8d_f2j_kxgc40000gn/T//ccRqrxDG.s
GNU C++17 (MacPorts gcc14 14.2.0_1+stdlib_flag) version 14.2.0
(aarch64-apple-darwin21)
        compiled by GNU C version 14.2.0, GMP version 6.3.0, MPFR version
4.2.1, MPC version 1.3.1, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory
"/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/opt/local/include"
ignoring nonexistent directory
"/opt/local/lib/gcc14/gcc/aarch64-apple-darwin21/14.2.0/../../../../../aarch64-apple-darwin21/include"
ignoring nonexistent directory
"/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /opt/local/include/gcc14/c++/
 /opt/local/include/gcc14/c++//aarch64-apple-darwin21
 /opt/local/include/gcc14/c++//backward
 /opt/local/lib/gcc14/gcc/aarch64-apple-darwin21/14.2.0/include
 /opt/local/lib/gcc14/gcc/aarch64-apple-darwin21/14.2.0/include-fixed
 /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/include

/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/System/Library/Frameworks
End of search list.
Compiler executable checksum: 097b6198556cf1057729d77843a48044
COLLECT_GCC_OPTIONS='-v' '-o' 'program' '-mmacosx-version-min=12.0.0' 
'-nodefaultexport' '-mcpu=apple-m1' '-mlittle-endian' '-mabi=lp64' '-dumpdir'
'program-'
 /opt/local/bin/as -arch arm64 -v -mmacosx-version-min=12.0 -o
/var/folders/25/26kqmfp91r1f8d_f2j_kxgc40000gn/T//cci5phuM.o
/var/folders/25/26kqmfp91r1f8d_f2j_kxgc40000gn/T//ccRqrxDG.s
Apple clang version 13.1.6 (clang-1316.0.21.2.3)
Target: arm64-apple-darwin21.4.0
Thread model: posix
InstalledDir:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
-cc1as -triple arm64-apple-macosx12.0.0 -filetype obj -main-file-name
ccRqrxDG.s -target-cpu apple-m1 -target-feature +v8.5a -target-feature
+fp-armv8 -target-feature +neon -target-feature +crc -target-feature +crypto
-target-feature +dotprod -target-feature +fp16fml -target-feature +ras
-target-feature +lse -target-feature +rdm -target-feature +rcpc -target-feature
+zcm -target-feature +zcz -target-feature +fullfp16 -target-feature +sm4
-target-feature +sha3 -target-feature +sha2 -target-feature +aes
-fdebug-compilation-dir=/Users/misbah/desktop -dwarf-debug-producer "Apple
clang version 13.1.6 (clang-1316.0.21.2.3)" -dwarf-version=4 -mrelocation-model
pic --mrelax-relocations -mllvm -disable-aligned-alloc-awareness=1 -o
/var/folders/25/26kqmfp91r1f8d_f2j_kxgc40000gn/T//cci5phuM.o
/var/folders/25/26kqmfp91r1f8d_f2j_kxgc40000gn/T//ccRqrxDG.s
COMPILER_PATH=/opt/local/libexec/gcc/aarch64-apple-darwin21/14.2.0/:/opt/local/libexec/gcc/aarch64-apple-darwin21/14.2.0/:/opt/local/libexec/gcc/aarch64-apple-darwin21/:/opt/local/lib/gcc14/gcc/aarch64-apple-darwin21/14.2.0/:/opt/local/lib/gcc14/gcc/aarch64-apple-darwin21/
LIBRARY_PATH=/opt/local/lib/gcc14/gcc/aarch64-apple-darwin21/14.2.0/:/opt/local/lib/gcc14/gcc/aarch64-apple-darwin21/14.2.0/../../../
COLLECT_GCC_OPTIONS='-v' '-o' 'program' '-mmacosx-version-min=12.0.0' 
'-nodefaultexport' '-mcpu=apple-m1' '-mlittle-endian' '-mabi=lp64' '-dumpdir'
'program.'
 /opt/local/libexec/gcc/aarch64-apple-darwin21/14.2.0/collect2 -demangle
-syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/ -dynamic
-arch arm64 -platform_version macos 12.0.0 0.0 -o program
-L/opt/local/lib/gcc14/gcc/aarch64-apple-darwin21/14.2.0
-L/opt/local/lib/gcc14/gcc/aarch64-apple-darwin21/14.2.0/../../.. -lemutls_w
-lheapt_w /var/folders/25/26kqmfp91r1f8d_f2j_kxgc40000gn/T//cci5phuM.o -lstdc++
-lgcc -lSystem -no_compact_unwind -rpath /opt/local/lib/libgcc -rpath
@loader_path -rpath /opt/local/lib/gcc14/gcc/aarch64-apple-darwin21/14.2.0
-rpath /opt/local/lib/gcc14


My info:
Mac OS 12.3.1
M1 CPU

Reply via email to