android / android/ndk

system STL is not useful and should be removed

Open
#744 42 comments 0 reactions 0 assignees View on GitHub
cmake ndk-build
Dominant language
No language data
Stars
2.3k
Forks
310
PR merge metrics
No merged PRs in 30d

Description

#### Description

CppReference suggests `` should overload `std::abs` with versions taking (and returning) various floating-point types:
https://en.cppreference.com/w/cpp/numeric/math/fabs

With the `system` STL, this doesn't happen.

The latest NDK default compiler does generate a warning for this [though the suggested fix in the note clearly doesn't work for this STL]:
```
warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
note: use function 'std::abs' instead
note: include the header or explicitly provide a declaration for 'std::abs'
```

Minimal test project:
https://github.com/tangobravo/ndk-abs-test

Commenting out the following block in app/build.gradle to show it working in with the default STL implementations:
```
externalNativeBuild {
cmake {
arguments "-DANDROID_STL=system"
}
}
```

There are probably other cmath functions that should have overloads, but it was the `abs()` one that I was testing at the time when I noticed it. I realise the gnustl and stlport options are being removed, but I believe the system one is still supported as a reasonable "no STL" option (and remains the default with ndkBuild I think) so thought it worthwhile to file a bug.

#### Environment Details

OS X 10.12.6, Android Studio 3.0.1 [probably not important for this bug]
Using NDK bundle from Android Studio: 17.1.4828580

Contributor guide

Open the contributing guide

Research direction

Start with the linked ndk-abs-test project and its app/build.gradle, focusing on the ANDROID_STL=system configuration. Reproduce the missing floating-point std::abs overload with the system STL, compare it with the default STL implementations, and verify that the relevant cmath behavior works without the compiler warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.