Skip to content
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

MDEV-34112 Replace one operator name keyword #3243

Merged
merged 1 commit into from May 15, 2024

Conversation

HugoWenTD
Copy link
Contributor

@HugoWenTD HugoWenTD commented May 7, 2024

  • The Jira issue number for this PR is: MDEV-34112

Description

Alternative operator name keywords like and, or, xor, etc., are uncommon in MariaDB and can cause obscure build errors when the GCC flag -fno-operator-names is applied.

Description of -fno-operator-names:
https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html

Do not treat the operator name keywords and, bitand, bitor, compl, not, or and xor as synonyms as keywords.

Part of the build errors:

/local/p4clients/pkgbuild-LdLa_/workspace/src/RDSMariaDB/sql/sql_select.cc:11171:28: error: expected ‘)’ before ‘and’
11171 |     DBUG_ASSERT(sel >= 0.0 and sel <= 1.00001);
      |                            ^~~
/local/p4clients/pkgbuild-LdLa_/workspace/src/RDSMariaDB/include/my_global.h:372:44: note: in definition of macro ‘unlikely’
  372 | #define unlikely(x)     __builtin_expect(((x) != 0),0)
      |                                            ^
...

The build failure is caused by using alternative operator name keywords and introduced in commit b66cdbd.
Replace the and keyword with && and target on MariaDB 11.0+ branches which include the commit.

Release Notes

N/A

How can this PR be tested?

This is the only occurrence I found using the operator names. With this change, build succeeds with GCC flag -fno-operator-names.
Existing MTR tests and builds will verify there's no regression.

Basing the PR against the correct MariaDB version

  • This is a bug fix and the PR is based against the earliest maintained branch in which the bug can be reproduced.

PR quality check

  • I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
  • For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.

Copyright

All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@HugoWenTD HugoWenTD marked this pull request as ready for review May 7, 2024 23:19
Copy link
Contributor

@LinuxJedi LinuxJedi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, many thanks!

@vuvova
Copy link
Member

vuvova commented May 14, 2024

I'll also push 11a34e7 into 10.5

Alternative operator name keywords like `and`, `or`, `xor`, etc., are
uncommon in MariaDB and can cause obscure build errors when the GCC
flag `-fno-operator-names` is applied.

Description of `-fno-operator-names`:
https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html
> Do not treat the operator name keywords `and`, `bitand`, `bitor`,
> `compl`, `not`, `or` and `xor` as synonyms as keywords.

Part of the build errors:

    /local/p4clients/pkgbuild-LdLa_/workspace/src/RDSMariaDB/sql/sql_select.cc:11171:28: error: expected ‘)’ before ‘and’
    11171 |     DBUG_ASSERT(sel >= 0.0 and sel <= 1.00001);
          |                            ^~~
    /local/p4clients/pkgbuild-LdLa_/workspace/src/RDSMariaDB/include/my_global.h:372:44: note: in definition of macro ‘unlikely’
      372 | #define unlikely(x)     __builtin_expect(((x) != 0),0)
          |                                            ^
    ...

The build failure is caused by using alternative operator name keywords
`and` introduced in commit b66cdbd.
Replace the `and` keyword with `&&` and target on MariaDB 11.0+ branches
which include the commit.

All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the
BSD-new license. I am contributing on behalf of my employer
Amazon Web Services, Inc.
@vuvova vuvova enabled auto-merge (rebase) May 15, 2024 08:39
@vuvova vuvova merged commit d1e230d into MariaDB:11.0 May 15, 2024
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants