Skip to content

[libcu++] Add [[nodiscard]] to numeric_limits methods - #12594

Merged
davebayer merged 2 commits into
NVIDIA:mainfrom
davebayer:add_nodiscard_numeric_limits
Nov 11, 2026
Merged

davebayer merged 2 commits into
NVIDIA:mainfrom
davebayer:add_nodiscard_numeric_limits

Conversation

@davebayer

Copy link
Copy Markdown
Contributor

No description provided.

@davebayer
davebayer requested a review from a team as a code owner November 11, 2026 08:20
@davebayer
davebayer requested a review from Jacobfaib November 11, 2026 08:20
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Nov 11, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Nov 11, 2026
@davebayer
davebayer enabled auto-merge (squash) November 11, 2026 08:23
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Improvements
    • Numeric limit value functions across standard and extended numeric types now produce a compiler warning when their results are ignored, making unconsumed values more visible during development. Function signatures and returned values are unchanged, so existing calculations and calling patterns continue to behave as before. This applies to integral, Boolean, and floating-point numeric limits.

Value-returning functions in the standard and extended numeric limits implementations now use [[nodiscard]] and _CCCL_TRIVIAL_API. Their signatures, return values, and conditional implementations remain unchanged.

Changes: Numeric limits annotations

Layer / File(s) Summary
Standard numeric limits functions
libcudacxx/include/cuda/std/__limits/numeric_limits.h
The generic, integral, bool, float, double, and long double implementations add [[nodiscard]] and replace _CCCL_API with _CCCL_TRIVIAL_API for value-returning functions.
Extended numeric limits functions
libcudacxx/include/cuda/std/__limits/numeric_limits_ext.h
The NVFP16, NVBF16, NVFP8, NVFP6, NVFP4, and __float128 implementations make the same declaration changes. Return expressions and conditional implementations remain unchanged.

Possibly related issues

  • NVIDIA/cccl#3701: The issue tracks modernize-use-nodiscard and identifies [[nodiscard]] as a relevant API change.

Possibly related PRs

  • NVIDIA/cccl#12570: Adds the __nv_fp8_ue5m3 numeric limits specialization whose value-returning methods this change annotates.

Suggested reviewers: miscco

Change: Feature

Merge Risk: Minimal · up to 3e3cc

This change adds discard warnings and inlining attributes to numeric limits functions without altering their results. No concrete merge-blocking risk was established.

Architecture risk: Medium · up to 3e3cc

The change affects 1 system.

Changed systems: libcudacxx

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — libcudacxx (service) was modified; 2 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in libcudacxx/include/cuda/std/__limits/numeric_limits.h: The generic implementation’s min, max, and lowest declarations are now [[nodiscard]] and use _CCCL_TRIVIAL_API instead of _CCCL_API; signatures and return values are unchanged.
  • observed — Modified behavior in libcudacxx/include/cuda/std/__limits/numeric_limits.h: The generic implementation’s epsilon and round_error declarations receive the same attribute and API-macro change, with behavior unchanged.
  • observed — Modified behavior in libcudacxx/include/cuda/std/__limits/numeric_limits.h: The generic implementation’s infinity, NaN, and denormal-minimum declarations receive the same attribute and API-macro change; their bodies are unchanged.
  • observed — Modified behavior in libcudacxx/include/cuda/std/__limits/numeric_limits.h: The integral implementation’s min, max, lowest, epsilon, and round_error declarations now use [[nodiscard]] and _CCCL_TRIVIAL_API; calculation and return behavior are unchanged.

Reliability and maintainability

  • inferred — Risk-relevant change factors for libcudacxx: blast_radius_1; direct_dependents_1
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: NVIDIA/cccl
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: d7a640d
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 71bccb36-d31f-47cb-a835-342e5875f29a
Commits

Reviewing files that changed from the base of the PR and between 13ed22f and 3e3cc7e.

Files selected for processing: 2

  • libcudacxx/include/cuda/std/__limits/numeric_limits.h
  • libcudacxx/include/cuda/std/__limits/numeric_limits_ext.h

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nitpick comments: 1

libcudacxx/include/cuda/std/__limits/numeric_limits.h: 1

98-98: Trivial · Maintainability & Code Quality · Quick win

suggestion: Test the new discard diagnostics.

The supplied max.pass.cpp consumes the results, so it does not check the new diagnostic. Add diagnostic tests for discarded and explicitly void-cast results across representative standard and extended types.

Review info

Run configuration

  • Source mode: Auto
  • Repository: NVIDIA/cccl
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: d7a640d
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 30add87e-79d4-4bae-8436-109afe53a7f6
Commits

Reviewing files that changed from the base of the PR and between d7a640d and 13ed22f.

Files selected for processing: 2

  • libcudacxx/include/cuda/std/__limits/numeric_limits.h
  • libcudacxx/include/cuda/std/__limits/numeric_limits_ext.h

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 7h 05m: Pass: 100%/230 | Total: 13d 08h | Max: 5h 59m | Hits: 29%/8510733

See results here.

@davebayer
davebayer merged commit e37713a into NVIDIA:main Nov 11, 2026
494 of 498 checks passed
@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants