Skip to content

Improve C2135 error reference #5658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions docs/error-messages/compiler-errors-1/compiler-error-c2135.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
---
title: "Compiler Error C2135"
description: "Learn more about: Compiler Error C2135"
ms.date: 11/04/2016
ms.date: 08/13/2025
f1_keywords: ["C2135"]
helpviewer_keywords: ["C2135"]
---
# Compiler Error C2135

> 'bit operator' : illegal bit field operation
> '*identifier*': you cannot apply '*operator*' to a bit-field

## Remarks

The address-of operator (`&`) cannot be applied to a bit field.
The [address-of operator (`&`)](../../cpp/address-of-operator-amp.md), [unary plus operator (`+`)](../../cpp/unary-plus-and-negation-operators-plus-and.md), [unary negation operator (`-`)](../../cpp/unary-plus-and-negation-operators-plus-and.md), [logical negation operator (`!`)](../../cpp/logical-negation-operator-exclpt.md), [one's complement operator (`~`)](../../cpp/one-s-complement-operator-tilde.md), and [indirection operator (`*`)](../../cpp/indirection-operator-star.md) cannot be applied to a bit-field in this context.

## Example

The following example generates C2135:

```cpp
// C2135.cpp
struct S {
int i : 1;
};

struct T {
int j;
struct S
{
int bit_field : 1;
int integer;
};
int main() {
&S::i; // C2135 address of a bit field
&T::j; // OK

int main()
{
&S::bit_field; // C2135
&S::integer; // OK
}
```

## See also

[C2104](compiler-error-c2104.md)