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

Incorrect documentation for @cmpxchgStrong and @cmpxchgWeak #19979

Open
oliver-giersch opened this issue May 16, 2024 · 2 comments
Open

Incorrect documentation for @cmpxchgStrong and @cmpxchgWeak #19979

oliver-giersch opened this issue May 16, 2024 · 2 comments
Labels
bug Observed behavior contradicts documented or intended behavior docs
Milestone

Comments

@oliver-giersch
Copy link

Zig Version

0.12.0

Steps to Reproduce and Observed Behavior

The documentation for @cmpxchgStrong and @cmpxchgWeak says:

This function performs a [strong|weak] atomic compare-and-exchange operation, returning `null` if the current value is not the given expected value.
It's the equivalent of this code, except atomic: 

[...]

This is wrong and does not match the behavior of either the builtin nor the code example below these descriptions.
I would like to open a PR for this, but I am unsure in which file to implement it, my assumption was doc/langref.html.in but that appears to be auto-generated.

Expected Behavior

I would propose the following wording:

This function performs a [strong|weak] atomic compare-and-exchange operation, returning `null` if the operation was successful and the previous value matched the given expected value.
Otherwise, it returns the actual value.
It's the equivalent of this code, except atomic:

[...]
@oliver-giersch oliver-giersch added the bug Observed behavior contradicts documented or intended behavior label May 16, 2024
@BratishkaErik
Copy link
Contributor

BratishkaErik commented May 16, 2024

I would like to open a PR for this, but I am unsure in which file to implement it, my assumption was doc/langref.html.in but that appears to be auto-generated.

Your assumption was correct, doc/langref.html.in is main template is located (it's not auto-generated) and doc/langref/ is where code examples are located. They are then processed by doctest to add recorded outputs and by docgen to generate final langref.html file. These are from tools/, but build.zig has langref step that calls them automatically.

@Pyrolistical
Copy link
Contributor

Is this duplicate of #1516 ?

@Vexu Vexu added the docs label May 18, 2024
@Vexu Vexu added this to the 0.13.0 milestone May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior docs
Projects
None yet
Development

No branches or pull requests

4 participants