Index: src/wp-includes/functions.php
===================================================================
--- src/wp-includes/functions.php	(revision 45190)
+++ src/wp-includes/functions.php	(working copy)
@@ -2944,6 +2944,8 @@
  * @since 4.1.0 The `$title` and `$args` parameters were changed to optionally accept
  *              an integer to be used as the response code.
  * @since 5.1.0 The `$link_url`, `$link_text`, and `$exit` arguments were added.
+ * 
+ * @global WP_Query $wp_query
  *
  * @param string|WP_Error  $message Optional. Error message. If this is a WP_Error object,
  *                                  and not an Ajax or XML-RPC request, the error's messages are used.
@@ -2972,6 +2974,8 @@
  */
 function wp_die( $message = '', $title = '', $args = array() ) {
 
+	global $wp_query;
+
 	if ( is_int( $args ) ) {
 		$args = array( 'response' => $args );
 	} elseif ( is_int( $title ) ) {
@@ -3016,9 +3020,9 @@
 		 */
 		$function = apply_filters( 'wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler' );
 	} elseif ( wp_is_xml_request()
-		|| function_exists( 'is_feed' ) && is_feed()
-		|| function_exists( 'is_comment_feed' ) && is_comment_feed()
-		|| function_exists( 'is_trackback' ) && is_trackback() ) {
+		|| isset( $wp_query ) && function_exists( 'is_feed' ) && is_feed()
+		|| isset( $wp_query ) && function_exists( 'is_comment_feed' ) && is_comment_feed()
+		|| isset( $wp_query ) && function_exists( 'is_trackback' ) && is_trackback() ) {
 		/**
 		 * Filters the callback for killing WordPress execution for XML requests.
 		 *
Index: tests/phpunit/tests/includes/helpers.php
===================================================================
--- tests/phpunit/tests/includes/helpers.php	(revision 45190)
+++ tests/phpunit/tests/includes/helpers.php	(working copy)
@@ -378,6 +378,23 @@
 	}
 
 	/**
+	 * @ticket 46813
+	 */
+	public function test_wp_die_does_not_cause_doing_it_wrong_notice_without_wp_query_set() {
+		//Unset query to trigger _doing_it_wrong later
+		unset( $GLOBALS['wp_query'] );
+
+		try {
+			//run wp_die to test if _doing_it_wrong runs
+			wp_die();
+		} catch ( WPDieException $e ) {
+			//do nothing with exception regardless
+		}
+
+		$this->assertEmpty( $this->caught_doing_it_wrong );
+	}
+	
+	/**
 	 * This test is just a setup for the one that follows.
 	 *
 	 * @ticket 38196
