1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-16 14:01:05 +01:00
nix/src
Sergei Zimmerman 3e0129ce3b fix(libutil/posix-source-accessor.cc): get rid of use-after-move bug
Naming class member variables the same as constructor arguments is a very
slippery slope because of how member variable names get resolved. Compiler
is not very helpful here and we need static analysis to forbid this kind of
stuff.

The following example illustrates the cause quite well:

```cpp

struct B {
    B(int) {}
};

struct A {
    A(int b): b([&](){
        return b;
        static_assert(std::is_same_v<decltype(b), int>);
    }()) {
       static_assert(std::is_same_v<decltype(b), int>);
    }
    void member() {
        static_assert(std::is_same_v<decltype(b), B>);
    }
    B b;
};

int main() {
    A(1).member();
}
```

From N4861 6.5.1 Unqualified name lookup:

> In all the cases listed in [basic.lookup.unqual], the scopes are searched
> for a declaration in the order listed in each of the respective categories;
> name lookup ends as soon as a declaration is found for the name.
> If no declaration is found, the program is ill-formed.

In the affected code there was a use-after-move for all accesses in the constructor
body, but this UB wasn't triggered.

These types of errors are trivial to catch via clang-tidy's [clang-analyzer-cplusplus.Move].
2024-11-08 16:07:45 +03:00
..
build-remote build-remote: only allocate storeUri once 2024-07-25 14:04:03 +02:00
external-api-docs make doxygen build more silent 2024-10-22 09:53:49 +02:00
internal-api-docs make doxygen build more silent 2024-10-22 09:53:49 +02:00
libcmd Revert "Merge pull request #11804 from obsidiansystems/remove-old-make" 2024-11-07 13:46:37 +01:00
libexpr Revert "Merge pull request #11804 from obsidiansystems/remove-old-make" 2024-11-07 13:46:37 +01:00
libexpr-c Revert "Merge pull request #11804 from obsidiansystems/remove-old-make" 2024-11-07 13:46:37 +01:00
libexpr-test-support Revert "Merge pull request #11804 from obsidiansystems/remove-old-make" 2024-11-07 13:46:37 +01:00
libexpr-tests Revert "Merge pull request #11804 from obsidiansystems/remove-old-make" 2024-11-07 13:46:37 +01:00
libfetchers Revert "Merge pull request #11804 from obsidiansystems/remove-old-make" 2024-11-07 13:46:37 +01:00
libfetchers-tests Revert "Merge pull request #11804 from obsidiansystems/remove-old-make" 2024-11-07 13:46:37 +01:00
libflake Revert "Merge pull request #11804 from obsidiansystems/remove-old-make" 2024-11-07 13:46:37 +01:00
libflake-tests Revert "Merge pull request #11804 from obsidiansystems/remove-old-make" 2024-11-07 13:46:37 +01:00
libmain Merge pull request #11826 from DeterminateSystems/revert-11804 2024-11-08 12:04:55 +01:00
libmain-c Set Windows API version in Meson 2024-11-05 23:36:08 +11:00
libstore Revert "Merge pull request #11804 from obsidiansystems/remove-old-make" 2024-11-07 13:46:37 +01:00
libstore-c Revert "Merge pull request #11804 from obsidiansystems/remove-old-make" 2024-11-07 13:46:37 +01:00
libstore-test-support Revert "Merge pull request #11804 from obsidiansystems/remove-old-make" 2024-11-07 13:46:37 +01:00
libstore-tests Revert "Merge pull request #11804 from obsidiansystems/remove-old-make" 2024-11-07 13:46:37 +01:00
libutil fix(libutil/posix-source-accessor.cc): get rid of use-after-move bug 2024-11-08 16:07:45 +03:00
libutil-c Revert "Merge pull request #11804 from obsidiansystems/remove-old-make" 2024-11-07 13:46:37 +01:00
libutil-test-support Revert "Merge pull request #11804 from obsidiansystems/remove-old-make" 2024-11-07 13:46:37 +01:00
libutil-tests Revert "Merge pull request #11804 from obsidiansystems/remove-old-make" 2024-11-07 13:46:37 +01:00
nix Merge pull request #11826 from DeterminateSystems/revert-11804 2024-11-08 12:04:55 +01:00
nix-build Fix compilation of nix-build on Windows 2024-11-04 11:53:49 +11:00
nix-channel Don't use OS_STR in nix-channel.cc 2024-08-18 18:27:20 +05:30
nix-collect-garbage More std::filesystem for nix-collect-garbage 2024-08-26 17:29:23 -04:00
nix-copy-closure Restrict some code to StoreDirConfig 2023-11-04 19:05:36 -04:00
nix-env MacOS built: add workaround for missing view() member of std::ostringstream 2024-10-07 02:05:53 +02:00
nix-instantiate No global settings in libnixfetchers and libnixflake 2024-07-12 08:50:28 -04:00
nix-store Clean up standard stream logic 2024-11-07 15:11:41 -05:00
perl Revert "Merge pull request #11804 from obsidiansystems/remove-old-make" 2024-11-07 13:46:37 +01:00
nix-functional-tests Build Functional tests with Meson 2024-08-14 15:35:40 -04:00
nix-manual Build the manual with Meson 2024-10-09 11:58:17 -04:00