llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.96k stars 11.53k forks source link

`locale::global` fails to initialize with curly braces #41826

Open llvmbot opened 5 years ago

llvmbot commented 5 years ago
Bugzilla Link 42481
Version unspecified
OS Linux
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@zygoloid,@TNorthover

Extended Description

Here is the syntax error I got. I copied the language off of page 1116 in "The C++ Programming Language" book so I know it should work.

./Anti-Terror/mainwindow.cpp:45:27: error: expected ')'
locale::global(locale {"en_US.UTF-8"});
^
../Anti-Terror/mainwindow.cpp:45:19: note: to match this '('
locale::global(locale {"en_US.UTF-8"});
TNorthover commented 5 years ago

This fragment works for me:

    #include <locale>
    void foo() {
      std::locale::global(std::locale{"en_US.UTF-8"});
    }

on macOS (clang-1100) and Linux (clang 7.0 & 8.0) provided it's compiled in at least C++11 mode.

Can you attach a self-contained example that fails with the error you're seeing, and tell us what versions you're using?