Skip to content

[libc++] std::regex_constants::ECMAScript mask not set #106460

Open
@androm3da

Description

@androm3da

This program fails with libc++ and passes for libstdc++. Is this the expected behavior?

#include <stdlib.h>
#include <regex>
#include <iostream>

using namespace std::regex_constants;

bool check(syntax_option_type a) {
  auto q = basic & (~basic);
  auto orig = a;
  if (a == q) {
      return false;
  }
  a &= ~q;
  if (a != orig) {
      return false;
  }
  return true;
}

int main() {
  if (!check(std::regex_constants::collate)) {
      std::cerr << "fail 'collate'\n";
      exit(1);
  }
  if (std::regex_constants::ECMAScript == (icase & (~icase))) {
      std::cerr << "Hmmm....\n";
  }
  if (!check(std::regex_constants::ECMAScript)) {
      std::cerr << "fail 'ECMAScript'\n";
      exit(1);
  }
}

Context:

$ clang++ ~/tmp/reg_const_ecma.cpp -stdlib=libc++ -std=c++20 && ./a.out ; echo $?
Hmmm....
fail 'ECMAScript'
1
$ clang++ ~/tmp/reg_const_ecma.cpp -std=c++20 && ./a.out ; echo $?
0
$ clang++ --version
clang version 18.1.8
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/mnt/workspace/install/clang-latest/bin

Metadata

Metadata

Assignees

No one assigned

    Labels

    libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.regexIssues related to regex

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions