== Why is this an issue?

include::../../../shared_content/cfamily/line_splicing.adoc[]

_Line-splicing_ is often harmless and is sometimes used to improve the readability of macros:

[source,c]
----
#define LOG_FAILURE(CONDITION, MESSAGE) \
  do {                                  \
    if (!(CONDITION)) {                 \
      log(MESSAGE);                     \
    }                                   \
  } while (0)
----

Furthermore, _line-splicing_ does not apply inside {cpp}11 raw string literal.

However, the effect of _line-splicing_ in single-line comments (`//`) can be surprising, leading to unintentional code removal and possibly undefined behavior.

In the following example, the `return` expression is considered part of the previous comment.
The function has undefined behavior because it exits without returning a value.

[source,cpp]
----
bool isSpecialCharacter(char c)
{
  // Noncompliant comment: it ends with a backslash.
  // Characters considered special: [ ] \
  return 91 <= c && c <= 93;
}
----

Compilers may also delete whitespace characters between a backslash and the newline characters.
This practice is standard-compliant since {cpp}23.
In other words, trailing whitespaces do not disable _line-splicing_.

== Resources

=== Documentation

* {cpp} reference - https://en.cppreference.com/w/cpp/language/translation_phases[Phases of translation]

=== External coding guidelines

* MISRA C:2012, 3.2 - Line-splicing shall not be used in // comments

=== Related rules

* S1916 is a companion rule and detects trailing whitespace after `\`.

ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Remove line-splicing from this comment.


endif::env-github,rspecator-view[]
