Issue 124913
Summary Syntax error for overloaded operator[] in 32-bit address space
Labels new issue
Assignees
Reporter ararmine
    **x86-64 clang 19.1.0** issues a compilation error for the following example:
1. cat ex.cpp
```
struct value {
 public:
        operator int() const;
        struct value &operator[](const char * __ptr32 _param_1);
};

extern struct value *new_value();

int json_send_error(int status)
{
  struct value * v = new_value();
  (void)(*v)["error"];
  return 0;
}
```
2. clang ex.c -fms-extensions -S
```
ex.cpp:13:13: error: use of overloaded operator '[]' is ambiguous (with operand types 'struct value' and 'const char[6]')
   13 | (void)(*v)["error"];
      |         ~~~~^~~~~~~~
ex.xpp:5:23: note: candidate function
    5 |         struct value &operator[](const char * __ptr32 _param_1);
      |                       ^
ex.cpp:13:13: note: built-in candidate operator[](long, const char *)
   13 | (void)(*v)["error"];
      |             ^
1 error generated.
```
https://godbolt.org/z/dbvEGfz13

**x64 MSVC v.19** compiles successfully https://godbolt.org/z/qWc584f5f 
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to