Thank you, Philipp.

In case it is useful, the Compiler Explorer website allows users to experiment 
with this feature:

https://godbolt.org/z/jffvhnoG5

This will be misnamed as a C++ compiler in your browsers (something that I am 
trying to resolve with the site’s maintainers) but it is actually a fork of 
Clang configured to compile C.

--
Christopher Bazley
Staff Software Engineer, GPU team, Central Engineering Group
ARM Ltd, 110 Fulbourn Road, Cambridge, CB1 9NJ, UK.
Web:   http://www.arm.com/
________________________________
From: Philipp Klaus Krause <p...@spth.de>
Sent: 26 February 2025 10:22
To: Sdcc-User <sdcc-user@lists.sourceforge.net>
Cc: Chris Bazley <chris.baz...@arm.com>
Subject: _Optional

Dear SDCC users,

would an _Optional qualifier (see N3422 -
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3422.pdf for details)
be useful to you?

Basically, it would be a way for programmers to explicitly specify that
a pointer might be null.

This would allow the compiler to warn on missing null pointer checks, e.g.:

void f(_Optional char *p)
{
        *p = 0; // Warning here
}

void g(_Optional char *p)
{
        if(p)
                *p = 0; // No warning here
}

Since _Optional is essentially an opt-in mechanism, we would not get any
false warnings on existing code.

Philipp

IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to