Skip to content

Conversation

bonktree
Copy link
Contributor

@bonktree bonktree commented Aug 5, 2025

Quoting cppreference.com:

  (the [[noreturn]] attribute) Indicates that the function will not
  return control flow to the calling function after it finishes (e.g.
  functions that terminate the application, throw exceptions, loop
  indefinitely, etc.). This attribute applies to the name of the
  function being declared in function declarations only.
  
  If a function previously declared with `[[noreturn]]` is invoked and
  that invocation eventually returns, the behavior is runtime-undefined.

The SafeIntOn* member functions immediately throw, so if they are used in a function with non-void return type, g++ 14 issues a warning that there exist control paths in the function where no value is returned.

Fix this by marking the member functions explicitly noreturn.

This is needed so onnxruntime builds correctly with -Wall -Wextra.

…n-type

The `SafeIntOn*` member functions immediately throw, so if they are used
in a function with non-void return type, g++ 14 issues a warning that
there exist control paths in the function where no value is returned.

Quoting cppreference.com:
  (the `[[noreturn]]` attribute) Indicates that the function will not
  return control flow to the calling function after it finishes (e.g.
  functions that terminate the application, throw exceptions, loop
  indefinitely, etc.). This attribute applies to the name of the
  function being declared in function declarations only.
  
  If a function previously declared with `[[noreturn]]` is invoked and
  that invocation eventually returns, the behavior is runtime-undefined.

Fix this by marking the member functions explicitly noreturn.
@bonktree
Copy link
Contributor Author

bonktree commented Aug 5, 2025

Notably, in SafeInt.hpp all relevant member functions in SafeIntExceptionHandler<E> instantiations are marked as noreturn, grep for SAFEINT_NORETURN in the file.

@edgchen1
Copy link
Contributor

/azp run Windows x64 QNN CI Pipeline, Windows GPU Doc Gen CI Pipeline, Windows ARM64 QNN CI Pipeline, Win_TRT_Minimal_CUDA_Test_CI, Linux QNN CI Pipeline

Copy link

Azure Pipelines successfully started running 5 pipeline(s).

@snnn snnn merged commit 17ede5a into microsoft:main Aug 26, 2025
86 checks passed
gedoensmax pushed a commit to gedoensmax/onnxruntime that referenced this pull request Sep 2, 2025
Quoting cppreference.com:
```
  (the [[noreturn]] attribute) Indicates that the function will not
  return control flow to the calling function after it finishes (e.g.
  functions that terminate the application, throw exceptions, loop
  indefinitely, etc.). This attribute applies to the name of the
  function being declared in function declarations only.
  
  If a function previously declared with `[[noreturn]]` is invoked and
  that invocation eventually returns, the behavior is runtime-undefined.
```

The `SafeIntOn*` member functions immediately throw, so if they are used
in a function with non-void return type, g++ 14 issues a warning that
there exist control paths in the function where no value is returned.

Fix this by marking the member functions explicitly noreturn.

This is needed so onnxruntime builds correctly with `-Wall -Wextra`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants