lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 16 May 2023 14:39:10 -0700
From:   Andrew Morton <akpm@...ux-foundation.org>
To:     Alexey Dobriyan <adobriyan@...il.com>
Cc:     linux-kernel@...r.kernel.org,
        Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH 2/3] auto: add "auto" keyword as alias for __auto_type

On Tue, 16 May 2023 19:49:46 +0300 Alexey Dobriyan <adobriyan@...il.com> wrote:

> It has similar semantics to "auto" keyword from a language
> which can not be named on this mailing list, in particular:

Huh, 20 years ago C's auto meant "automatic variable".  ie, stored on
the stack.  It was never needed because that's the default, unless you
used `register', which gave the false impression that you're being
faster.

> 	{
> 		int a;
> 		const auto b = a; // const char b = a;

I assume that should be "const int b = a".

> 		b = 1;	// compile error
> 	}
> 	{
> 		char a;
> 		auto b = a; // char b = a;
> 		// no integer promotions
> 		static_assert(sizeof(b) == 1);
> 	}
> 	{
> 		int a;
> 		const auto p = &a; // int *const p = &a;
> 		*p = 1;	// works because const is applied only to top-level
> 	}
> 
> It can be used to save on macroexpansion inside macro forests which
> use typeof() somewhere deep enough. It is cool regardless.
> 
> Use "auto" in your code today!
> 
> gcc 5.1 supports __auto_type.
> 
> Signed-off-by: Alexey Dobriyan <adobriyan@...il.com>
> ---
>  Makefile | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/Makefile b/Makefile
> index 10fcc64fcd1f..d316924a466a 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -570,6 +570,7 @@ KBUILD_CFLAGS += -Werror=return-type
>  KBUILD_CFLAGS += -Werror=strict-prototypes
>  KBUILD_CFLAGS += -Wno-format-security
>  KBUILD_CFLAGS += -Wno-trigraphs
> +KBUILD_CFLAGS += -Dauto=__auto_type
>  
>  KBUILD_CPPFLAGS := -D__KERNEL__
>  KBUILD_RUSTFLAGS := $(rust_common_flags) \

Examples at https://lkml.kernel.org/r/20230516164947.86543-3-adobriyan@gmail.com

It is pretty cool and could get used a lot.  Cc Linus for his thoughts?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ