|
Message-ID: <DS7PR12MB5765F16709CDBF45D6DB0A31CBE6A@DS7PR12MB5765.namprd12.prod.outlook.com> Date: Wed, 30 Aug 2023 15:04:50 -0700 From: Fangrui Song <i@...kray.me> To: musl@...ts.openwall.com Subject: Re: [PATCH] Use __builtin_FILE/__builtin_LINE if available On Sat, Mar 4, 2023 at 7:23 PM Zhihao Yuan <lichray@...il.com> wrote: > > On Thu, Mar 2, 2023 at 12:19 AM Fangrui Song <i@...kray.me> wrote: >> >> On Mon, Feb 27, 2023 at 2:27 PM Szabolcs Nagy <nsz@...t70.net> wrote: >> > > > It is sad that C++ modules broke 'assert' but not surprising. Modules were largely created out of aversion to macros. This isn't something libc can fix though, I suggest a defect report against C++ instead. >> >> To lichray: ^^ > > > The definition of 'assert' is mandatory only when NDEBUG > is defined as a macro name. 7.2.1.1 reads: > > "[...], if expression (which shall have a scalar type) is false (that is, compares equal to 0), > the assert macro writes information about the particular call that failed (including the text of the > argument, the name of the source file, the source line number, and the name of the enclosing function > — the latter are respectively the values of the preprocessing macros __FILE__ and __LINE__ and of > the identifier __func__) on the standard error stream in an implementation-defined format." > > The text in parentheses did not mandate the use of __FILE__ > and __LINE__, and C++ did not permit 'assert' not to work in > modules. Therefore an implementation that fails to compile > the code snippet in the original email is not conforming. >> >> >> > > > Changing the semantics of assert in C seems like a bad thing to do. >> > > > > > > The semantics is unchanged, and people are doing it: > > Add custom ODR-safe assert. (!1166) · Merge requests · libeigen / eigen · GitLab > >> >> > >> > i dont see how that solves the fundamental problem: >> > >> > the *behavior* of assert changes depending on which include path is >> > used and thus inline functions that are supposed to be equivalent >> > aren't. (__builtin_FILE makes the pp-token sequence the same across >> > the instances, but the actual code will have different paths, which >> > while not an odr violation per the literal words of the spec, it >> > clearly violates the reason the rule is there in the first place.) > > > This is a different topic. In related news, CWG Issue 2678 (cplusplus.github.io) > will likely need to be revisited (i.e., what does 'odr' mean > is subject to change). Regardless, __builtin_FILE is > a vendor extension and serves customers' needs in > implementing 'assert.' > > -- > Zhihao Yuan, ID lichray > The best way to predict the future is to invent it. > _______________________________________________ Bump:)
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.