tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Proposal to stop redefining __func__ for C++11 and newer



(let me put my devil's advocate hat on)

On Sat 01 Dec 2018 at 22:14:40 +0100, Kamil Rytarowski wrote:
> According to C++ papers, __func__ is an implementation-defined string.

(in C++14, it's in 8.1.4.8)

And therefore, users can't depend on any particular value.

> However the current version causes a mismatch between NetBSD and the world:

NetBSD:
> $ ./a.out
> int main(int, char **)

others:
> $ ./a.out
> main

> While both versions are compliant with C++11, this causes unnecessary
> difference in regression tests, in particular in the LLVM project.

I would argue that if the LLVM project depends on any particular value
of __func__, they are wrong.

The value that is provided by NetBSD is more useful. In C++, "main"
isn't terribly useful information; it doesn't tell you if you're in "int
main(int, char **)" or perhaps in "void main(char *, float)", which is a
totally different function.

I see no point in reducing our value if we're in compliance with the
Standard and some other part of the world is not.

(devil's advocate hat off)

Current drafts seem to have the same wording as in older Standards, so
this gives us no guidance about what the C++ committee thought:

    The function-local predefined variable \tcode{__func__} is
    defined as if a definition of the form
    \begin{codeblock}
    static const char __func__[] = "@\placeholder{function-name}@";
    \end{codeblock}
    had been provided, where \tcode{\placeholder{function-name}} is an
    \impldef{string resulting
    from \mname{func}} string.

(source: https://github.com/cplusplus/draft.git )
(\impldef{string resulting from \mname{func}} is the index entry:
 "string resulting from __func__")

-Olaf.
-- 
___ Olaf 'Rhialto' Seibert  -- "What good is a Ring of Power
\X/ rhialto/at/falu.nl      -- if you're unable...to Speak." - Agent Elrond

Attachment: signature.asc
Description: PGP signature



Home | Main Index | Thread Index | Old Index